summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.org>2004-08-12 11:54:16 +0000
committerOlivier Blin <oblin@mandriva.org>2004-08-12 11:54:16 +0000
commit9a179b8bdb0fc71e8bccd9bb10657da780f0dd2a (patch)
tree2302a6c959e96a0a0dd3f35ceb06cd3b5d726b1b /mdk-stage1
parente65ee3a8a3caf124d81a488c69331e93af541f24 (diff)
downloaddrakx-9a179b8bdb0fc71e8bccd9bb10657da780f0dd2a.tar
drakx-9a179b8bdb0fc71e8bccd9bb10657da780f0dd2a.tar.gz
drakx-9a179b8bdb0fc71e8bccd9bb10657da780f0dd2a.tar.bz2
drakx-9a179b8bdb0fc71e8bccd9bb10657da780f0dd2a.tar.xz
drakx-9a179b8bdb0fc71e8bccd9bb10657da780f0dd2a.zip
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)
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/init.c27
1 files changed, 15 insertions, 12 deletions
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);