commit 7c78c8a38cabeb8f5d4ebb64383f6681dadcad11
parent 4d4cb5bc9887ec72109d456fe721562f5bc71403
Author: Gerrit Pape <pape@smarden.org>
Date: Sat, 7 Oct 2006 18:25:29 +0000
* 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:
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/package/CHANGES b/package/CHANGES
@@ -1,10 +1,13 @@
1.7.0
-Sun, 30 Jul 2006 12:32:48 +0000
+Sat, 07 Oct 2006 18:24:17 +0000
* svlogd.c, fmt_ptime.*, man/svlogd.8: new option -ttt: prefix log
messages with sortable UTC timestamp YYYY-MM-DDTHH:MM:SS.xxxxx.
* runsv.c, runsv.8: give two arguments to ./finish: exit code and exit
status of ./run (mostly copied from pipe-tools' npt-supervise, thx
Laurent Bercot).
+ * 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).
1.6.0
Thu, 29 Jun 2006 07:52:35 +0000
diff --git 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();