From 9a179b8bdb0fc71e8bccd9bb10657da780f0dd2a Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Thu, 12 Aug 2004 11:54:16 +0000 Subject: restart forked process if it exits with exit_value_restart as return code (thanks to Rafael for the choice of its value, 0x35 is the translation of RS, abbreviation of ReStart, in his local l33t dialect, and happens to be 53 in its decimal form, which is quite nice) --- mdk-stage1/init.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'mdk-stage1/init.c') diff --git a/mdk-stage1/init.c b/mdk-stage1/init.c index 3aada32bb..24bc373a6 100644 --- a/mdk-stage1/init.c +++ b/mdk-stage1/init.c @@ -430,6 +430,7 @@ int in_reboot(void) } int exit_value_proceed = 66; +int exit_value_restart = 0x35; int main(int argc, char **argv) { @@ -504,20 +505,22 @@ int main(int argc, char **argv) 2) we receive a SIGHUP */ - if (!(installpid = fork())) { - /* child */ - char * child_argv[2]; - child_argv[0] = BINARY; - child_argv[1] = NULL; + do { + if (!(installpid = fork())) { + /* child */ + char * child_argv[2]; + child_argv[0] = BINARY; + child_argv[1] = NULL; - execve(child_argv[0], child_argv, env); - printf("error in exec of %s :-( [%d]\n", BINARY, errno); - return 0; - } + execve(child_argv[0], child_argv, env); + printf("error in exec of %s :-( [%d]\n", BINARY, errno); + return 0; + } - do { - childpid = wait4(-1, &wait_status, 0, NULL); - } while (childpid != installpid); + do { + childpid = wait4(-1, &wait_status, 0, NULL); + } while (childpid != installpid); + } while (WIFEXITED(wait_status) && WEXITSTATUS(wait_status) == exit_value_restart); /* allow Ctrl Alt Del to reboot */ reboot(0xfee1dead, 672274793, BMAGIC_HARD); -- cgit v1.2.1