]> xenbits.xensource.com Git - osstest/rumprun.git/commitdiff
Fail gracefully if some bootstrap routine calls exit.
authorAntti Kantee <pooka@iki.fi>
Wed, 21 Oct 2015 21:28:43 +0000 (21:28 +0000)
committerAntti Kantee <pooka@iki.fi>
Wed, 21 Oct 2015 21:28:43 +0000 (21:28 +0000)
include/rumprun-base/rumprun.h
lib/librumprun_base/rumprun.c
lib/librumprun_base/syscall_misc.c

index 0c6624d2d6182e95125c9bf78ee0a1ee125472c4..fb5b59ce79f885954efa01aa4b977e725c9a95a0 100644 (file)
@@ -40,4 +40,6 @@ void  rumprun_reboot(void) __attribute__((noreturn));
 /* XXX: this prototype shouldn't be here (if it should exist at all) */
 void   rumprun_daemon(void);
 
+extern int rumprun_cold;
+
 #endif /* _RUMPRUN_BASE_RUMPRUN_H_ */
index 37146c8f1c7cef8d69b917da394d054797eafda3..3e630c5f19ede32179b29a4ccfdae9460439a27c 100644 (file)
@@ -73,6 +73,8 @@ __weak_alias(rumpbake_main8,rumprun_notmain);
 
 __weak_alias(rump_init_server,rumprun_enosys);
 
+int rumprun_cold = 1;
+
 void
 rumprun_boot(char *cmdline)
 {
@@ -128,6 +130,8 @@ rumprun_boot(char *cmdline)
 
        pthread_mutex_init(&w_mtx, NULL);
        pthread_cond_init(&w_cv, NULL);
+
+       rumprun_cold = 0;
 }
 
 /*
index e9ead0540729ebe6dab1a49e91bcbc258f9b9453..cc00f2d0292e268a3fd3b2f437bca81302a162c8 100644 (file)
 #include <time.h>
 #include <unistd.h>
 
+#include <rumprun-base/rumprun.h>
+
 void __dead
 _exit(int eval)
 {
+
+       if (__predict_false(rumprun_cold)) {
+               printf("\n=== bootstrap failed\n");
+               reboot(0, NULL);
+               /*NOTREACHED*/
+       }
+
        if (eval) {
                printf("\n=== ERROR: _exit(%d) called ===\n", eval);
        } else {