runtime: fix "may be uninitialized" warnings

When compiling with -O3 gcc detects that 'th' may be uninitialized.
This is true, it happens when prio_find_thread is given
which == PRIO_USER or which == PRIO_PGRP.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
core: extract graceful shutdown logic

In order to reuse the logic it needs to be extracted.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
runtime: call shutdown() on exit()

Currently we just call poweroff() which does not umount
file systems which leads to data loss on next boot.

This happens for example if you start the CLI and type exit. On next
boot you will get:

 TX_CREATE
 TX_CREATE
 Solaris: WARNING: ZFS replay transaction error 95, dataset osv/zfs,
 seq 0x1, txtype 2

Reported-by: Pekka Enberg <penberg@cloudius-systems.com>
Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>