diff options
author | Gerrit Pape <pape@smarden.org> | 2006-10-07 18:25:29 +0000 |
---|---|---|
committer | Gerrit Pape <pape@smarden.org> | 2006-10-07 18:25:29 +0000 |
commit | 09434bbfac4d39cc7de8e15bbe10f59cb1297388 (patch) | |
tree | ec83b0b26c678049208f813f19861ac6a9dce7fd /src | |
parent | 813757149ddb7ab211fc5fd069fc66abf9cf1b32 (diff) | |
download | runit-09434bbfac4d39cc7de8e15bbe10f59cb1297388.tar.gz runit-09434bbfac4d39cc7de8e15bbe10f59cb1297388.tar.xz runit-09434bbfac4d39cc7de8e15bbe10f59cb1297388.zip |
* runit.c: don't make console the controlling terminal for process 1,
but for stage 1 only; fork before initiating system halt or reboot, the linux kernel calls do_exit(0) in kernel/sys.c (thx Jan Kampe).
Diffstat (limited to 'src')
-rw-r--r-- | src/runit.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/runit.c b/src/runit.c index 3386155..46e10b7 100644 --- a/src/runit.c +++ b/src/runit.c @@ -70,9 +70,6 @@ int main (int argc, const char * const *argv, char * const *envp) { /* console */ if ((ttyfd =open_write("/dev/console")) != -1) { -#ifdef TIOCSCTTY - ioctl(ttyfd, TIOCSCTTY, (char *)0); -#endif dup2(ttyfd, 0); dup2(ttyfd, 1); dup2(ttyfd, 2); if (ttyfd > 2) close(ttyfd); } @@ -111,6 +108,9 @@ int main (int argc, const char * const *argv, char * const *envp) { /* stage 1 gets full control of console */ if (st == 0) { if ((ttyfd =open("/dev/console", O_RDWR)) != -1) { +#ifdef TIOCSCTTY + ioctl(ttyfd, TIOCSCTTY, (char *)0); +#endif dup2(ttyfd, 0); if (ttyfd > 2) close(ttyfd); } @@ -294,6 +294,10 @@ int main (int argc, const char * const *argv, char * const *envp) { strerr_warn2(INFO, "sending KILL signal to all processes...", 0); kill(-1, SIGKILL); + pid =fork(); + switch (pid) { + case 0: + case -1: if ((stat(REBOOT, &s) != -1) && (s.st_mode & S_IXUSR)) { strerr_warn2(INFO, "system reboot.", 0); sync(); @@ -322,6 +326,12 @@ int main (int argc, const char * const *argv, char * const *envp) { #endif #endif } + if (pid == 0) _exit(0); + break; + default: + sig_unblock(sig_child); + while (wait_pid(pid, 0, 0) == -1); + } #endif for (;;) sig_pause(); |