runit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit db17f1be219f29c9e07b0ae65b89758d31e6bf68
parent 85ee27d2791d0335f66a5a44565b19ebc6a8c627
Author: Gerrit Pape <pape@smarden.org>
Date:   Mon, 26 Nov 2001 11:31:53 +0000

  * runit-halt, runit-reboot removed, integrated into runit-init
  * tested with dietlibc
  * doc: usedietlibs.html added.

Diffstat:
MMakefile | 4++--
Mdebian/conffiles | 2--
Mdebian/postinst | 2+-
Mdebian/rules | 44++++++++++++++++++++++----------------------
Mdoc/index.html | 23+++++++++++++++++------
Mdoc/install.html | 12+++++-------
Mdoc/replaceinit.html | 8++++----
Ddoc/runit-halt.8.html | 41-----------------------------------------
Ddoc/runit-reboot.8.html | 41-----------------------------------------
Dman/runit-halt.8 | 35-----------------------------------
Mman/runit-init.8 | 28+++++++++++++++++++---------
Dman/runit-reboot.8 | 35-----------------------------------
Mman/runit.8 | 8++++----
Mpackage/CHANGES | 7+++++++
Mpackage/commands | 2--
Mpackage/compile | 8+++++---
Mpackage/upgrade | 4++--
Msrc/init.c | 62+++++++++++++++++++++++++++++++++++++++++++++-----------------
Dsrc/runit-halt | 7-------
Dsrc/runit-reboot | 6------
Msrc/runit.c | 25+++++++++++++------------
21 files changed, 146 insertions(+), 258 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,8 +1,8 @@ DESTDIR= -PACKAGE=runit-0.1.2 +PACKAGE=runit-0.2.0 DIRS=doc man etc package src -MANPAGES=man/runit.8 man/runit-init.8 man/runit-halt.8 man/runit-reboot.8 +MANPAGES=man/runit.8 man/runit-init.8 DAEMONTOOLS_PD=daemontools-pd-0.76 all: clean .manpages $(DAEMONTOOLS_PD).tar.gz $(PACKAGE).tar.gz diff --git a/debian/conffiles b/debian/conffiles @@ -2,5 +2,3 @@ /etc/runit/2 /etc/runit/3 /etc/runit/ctrlaltdel -/sbin/runit-halt -/sbin/runit-reboot diff --git a/debian/postinst b/debian/postinst @@ -25,7 +25,7 @@ set -e case "$1" in configure) ( \ - cd /package/admin/runit-0.1.2 + cd /package/admin/runit-0.2.0 package/upgrade ) ;; diff --git a/debian/rules b/debian/rules @@ -24,18 +24,18 @@ build-stamp: # $(MAKE) #/usr/bin/docbook-to-man debian/runit.sgml > runit.1 - tar xfzvp runit-0.1.2.tar.gz - mkdir -p admin/runit-0.1.2/compile + tar xfzvp runit-0.2.0.tar.gz + mkdir -p admin/runit-0.2.0/compile tar xfzvp daemontools-pd-0.76.tar.gz \ - -C admin/runit-0.1.2/compile - ( cd admin/runit-0.1.2/compile ; \ + -C admin/runit-0.2.0/compile + ( cd admin/runit-0.2.0/compile ; \ ln -s daemontools-pd-0.76 support ) ( \ - cd admin/runit-0.1.2 ; \ + cd admin/runit-0.2.0 ; \ package/compile ; \ - echo "/package/admin/runit-0.1.2" > compile/home ; \ + echo "/package/admin/runit-0.2.0" > compile/home ; \ rm -f compile/src ; \ - ln -s /package/admin/runit-0.1.2/src compile/src ; \ + ln -s /package/admin/runit-0.2.0/src compile/src ; \ ) touch build-stamp @@ -62,40 +62,40 @@ install: build chmod 1755 debian/runit/package cp -a admin debian/runit/package/ - rm -rf debian/runit/package/admin/runit-0.1.2/compile - cp -a debian/runit/package/admin/runit-0.1.2/man . - rm -rf debian/runit/package/admin/runit-0.1.2/man - cp -a debian/runit/package/admin/runit-0.1.2/doc . - rm -rf debian/runit/package/admin/runit-0.1.2/doc - cp -a debian/runit/package/admin/runit-0.1.2/etc . - rm -rf debian/runit/package/admin/runit-0.1.2/etc - cp -a debian/runit/package/admin/runit-0.1.2/package . + rm -rf debian/runit/package/admin/runit-0.2.0/compile + cp -a debian/runit/package/admin/runit-0.2.0/man . + rm -rf debian/runit/package/admin/runit-0.2.0/man + cp -a debian/runit/package/admin/runit-0.2.0/doc . + rm -rf debian/runit/package/admin/runit-0.2.0/doc + cp -a debian/runit/package/admin/runit-0.2.0/etc . + rm -rf debian/runit/package/admin/runit-0.2.0/etc + cp -a debian/runit/package/admin/runit-0.2.0/package . # /etc/runit - cp -p admin/runit-0.1.2/etc/debian/[123] \ + cp -p admin/runit-0.2.0/etc/debian/[123] \ debian/runit/etc/runit/ - cp -p admin/runit-0.1.2/etc/debian/ctrlaltdel \ + cp -p admin/runit-0.2.0/etc/debian/ctrlaltdel \ debian/runit/etc/runit/ - cp -p admin/runit-0.1.2/etc/debian/getty-tty5/run \ + cp -p admin/runit-0.2.0/etc/debian/getty-tty5/run \ debian/runit/etc/runit/getty-tty5 # runit programs - cp -p debian/runit/package/admin/runit-0.1.2/command/runit* \ + cp -p debian/runit/package/admin/runit-0.2.0/command/runit* \ debian/runit/sbin/ # cleanup - rm -rf debian/runit/package/admin/runit-0.1.2/compile + rm -rf debian/runit/package/admin/runit-0.2.0/compile # create debian/links rm -f debian/links for i in \ - `cat debian/runit/package/admin/runit-0.1.2/package/commands` ; \ + `cat debian/runit/package/admin/runit-0.2.0/package/commands` ; \ do \ echo "/package/admin/runit/command/$$i /command/$$i" \ >> debian/links ; \ done # for i in \ -# `cat debian/runit/package/admin/runit-0.1.2/package/commands` ; \ +# `cat debian/runit/package/admin/runit-0.2.0/package/commands` ; \ # do \ # echo "/command/$$i /usr/local/bin/$$i" \ # >> debian/links ; \ diff --git a/doc/index.html b/doc/index.html @@ -9,12 +9,11 @@ <h1>runit - minimal replacement for <i>sysvinit</i></h1> <hr> <a href="install.html">How to install runit</a><br> -<a href="replaceinit.html">How to replace init</a> +<a href="replaceinit.html">How to replace init</a><br> +<a href="usedietlibc.html">How to use dietlibc</a> <p> <a href="runit.8.html">The <tt>runit</tt> program</a><br> -<a href="runit-init.8.html">The <tt>runit-init</tt> program</a><br> -<a href="runit-halt.8.html">The <tt>runit-halt</tt> program</a><br> -<a href="runit-reboot.8.html">The <tt>runit-reboot</tt> program</a> +<a href="runit-init.8.html">The <tt>runit-init</tt> program</a> <hr> <i>runit</i> cooperates with djb's <a href="http://cr.yp.to/daemontools.html">daemontools</a> package to create @@ -67,8 +66,20 @@ done in other programs, see Dependencies and runlevels</a> for an example, the amount of code in process no 1 should be minimal. <hr> -See <a href="replaceinit.html">How to replace init</a> for smoothly migrating -from <i>sysvinit</i>. +See <a href="install.html">How to install runit</a> for installing +<i>runit</i> and <a href="replaceinit.html">How to replace init</a> for +smoothly escaping from <i>sysvinit</i>. +<hr> +If <i>runit</i> is compiled and linked with +<a href="http://www.fefe.de/dietlibc/">dietlibc</a> it yields in a statically +linked <tt>runit</tt> binary of 14k size and this <tt>ps axuw</tt> output +on my system: +<pre> + USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND + root 1 0.0 0.0 24 20 ? S Nov22 0:01 runit +</pre> +I recommend doing this; for instructions, see +<a href="usedietlibc.html">How to use dietlibc</a>. <hr> See <a href="http://smarden.org/runit/">http://smarden.org/runit/</a> for recent informations. diff --git a/doc/install.html b/doc/install.html @@ -13,14 +13,14 @@ Check that you have the recent version of <a href="http://cr.yp.to/daemontools.html">daemontools</a> installed. <p> Download -<a href="runit-0.1.2.tar.gz">runit-0.1.2.tar.gz</a> into <tt>/package</tt> +<a href="runit-0.2.0.tar.gz">runit-0.2.0.tar.gz</a> into <tt>/package</tt> and unpack the archive <pre> # cd /package - # gunzip runit-0.1.2.tar - # tar -xpf runit-0.1.2.tar - # rm runit-0.1.2.tar - # cd admin/runit-0.1.2 + # gunzip runit-0.2.0.tar + # tar -xpf runit-0.2.0.tar + # rm runit-0.2.0.tar + # cd admin/runit-0.2.0 </pre> Compile and install the <i>runit</i> programs <pre> @@ -32,8 +32,6 @@ gzip the man pages and copy them into a reasonable directory in your # mkdir -p /usr/local/man/man8/ # gzip man/runit.8 && cp -f man/runit.8.gz /usr/local/man/man8/ # gzip man/runit-init.8 && cp -f man/runit-init.8.gz /usr/local/man/man8/ - # gzip man/runit-halt.8 && cp -f man/runit-halt.8.gz /usr/local/man/man8/ - # gzip man/runit-reboot.8 && cp -f man/runit-reboot.8.gz /usr/local/man/man8/ </pre> Refer to <a href="replaceinit.html">replacing init</a> for replacing <i>sysvinit</i> with <i>runit</i>. diff --git a/doc/replaceinit.html b/doc/replaceinit.html @@ -84,9 +84,9 @@ It is possible to just add <tt>/etc/init.d/rc 2</tt> for having all services from the former runlevel 2 started as one time tasks, but keep the goal above in mind, supervising services has great advantages. <p> -Repeat step 4 and 5, using <tt>/sbin/runit-reboot</tt> to reboot the system, -until your are satisfied with your services startup. If anything goes wrong, -reboot the system with the default <i>sysvinit</i> <tt>/sbin/init</tt> +Repeat step 4 and 5, using <tt><b>/sbin/runit-init 6</b></tt> to reboot the +system, until you are satisfied with your services startup. If anything goes +wrong, reboot the system into the default <i>sysvinit</i> <tt>/sbin/init</tt> and repair the <i>runit</i> stages, then start again at step 4. <h3>Step 6: Replace /sbin/init</h3> Now it is time to replace the <i>sysvinit</i> <tt>/sbin/init</tt> binary: @@ -102,7 +102,7 @@ default Unix process no 1 <i>runit</i>. </pre> To report success: <pre> - # ( uname -a ; cat /etc/runit/[123] ) | mail pape-runit-0.1.2@smarden.org + # ( uname -a ; cat /etc/runit/[123] ) | mail pape-runit-0.2.0@smarden.org </pre> <hr> <address><a href="mailto:pape@smarden.org"> diff --git a/doc/runit-halt.8.html b/doc/runit-halt.8.html @@ -1,41 +0,0 @@ - - - -<HTML> -<HEAD> -<TITLE>runit-halt(8) manual page</TITLE> -</HEAD> -<BODY bgcolor=white> -<a href="http://smarden.org/pape/">G. Pape</a><br><A HREF="index.html">runit</A><hr><P> - -<H2><A NAME="sect0">Name</A></H2> -runit-halt - stop the system -<H2><A NAME="sect1">Synopsis</A></H2> -<B>init</B> 0 <BR> -<B>runit-halt</B> -<H2><A NAME="sect2">Description</A></H2> -<B>runit-halt</B> causes the Unix process no 1 <B><I>runit</B>(8)</I> to -halt the system. Normally <B>runit-halt</B> is run by <B><I>runit-init</B>(8)</I> if called as -<B>init 0.</B> <P> -To signal <B><I>runit</B>(8)</I> the system halt request, <B>runit-halt</B> removes the -/etc/runit/reboot file and touches /etc/runit/stopit. Then a CONT signal -is sent to <B><I>runit</B>(8)</I>. -<H2><A NAME="sect3">Exit Codes</A></H2> -<B>runit-halt</B> always returns 0. -<H2><A NAME="sect4">See Also</A></H2> -<I>runit-init(8)</I>, -<I>runit(8)</I>, <I>runit-reboot(8)</I> -<H2><A NAME="sect5">Author</A></H2> -Gerrit Pape &lt;pape@smarden.org&gt; <P> - -<HR><P> -<A NAME="toc"><B>Table of Contents</B></A><P> -<UL> -<LI><A NAME="toc0" HREF="#sect0">Name</A></LI> -<LI><A NAME="toc1" HREF="#sect1">Synopsis</A></LI> -<LI><A NAME="toc2" HREF="#sect2">Description</A></LI> -<LI><A NAME="toc3" HREF="#sect3">Exit Codes</A></LI> -<LI><A NAME="toc4" HREF="#sect4">See Also</A></LI> -<LI><A NAME="toc5" HREF="#sect5">Author</A></LI> -</UL> -</BODY></HTML> diff --git a/doc/runit-reboot.8.html b/doc/runit-reboot.8.html @@ -1,41 +0,0 @@ - - - -<HTML> -<HEAD> -<TITLE>runit-reboot(8) manual page</TITLE> -</HEAD> -<BODY bgcolor=white> -<a href="http://smarden.org/pape/">G. Pape</a><br><A HREF="index.html">runit</A><hr><P> - -<H2><A NAME="sect0">Name</A></H2> -runit-reboot - reboot the system -<H2><A NAME="sect1">Synopsis</A></H2> -<B>init</B> 6 <BR> -<B>runit-reboot</B> -<H2><A NAME="sect2">Description</A></H2> -<B>runit-reboot</B> causes the Unix process no 1 <B><I>runit</B>(8)</I> -to reboot the system. Normally <B>runit-reboot</B> is run by <B><I>runit-init</B>(8)</I> if called -as <B>init 6.</B> <P> -To signal <B><I>runit</B>(8)</I> the system reboot request, <B>runit-reboot</B> touches -the /etc/runit/reboot and /etc/runit/stopit files. Then a CONT signal is -sent to <B><I>runit</B>(8)</I>. -<H2><A NAME="sect3">Exit Codes</A></H2> -<B>runit-reboot</B> always returns 0. -<H2><A NAME="sect4">See Also</A></H2> -<I>runit-init(8)</I>, -<I>runit(8)</I>, <I>runit-halt(8)</I> -<H2><A NAME="sect5">Author</A></H2> -Gerrit Pape &lt;pape@smarden.org&gt; <P> - -<HR><P> -<A NAME="toc"><B>Table of Contents</B></A><P> -<UL> -<LI><A NAME="toc0" HREF="#sect0">Name</A></LI> -<LI><A NAME="toc1" HREF="#sect1">Synopsis</A></LI> -<LI><A NAME="toc2" HREF="#sect2">Description</A></LI> -<LI><A NAME="toc3" HREF="#sect3">Exit Codes</A></LI> -<LI><A NAME="toc4" HREF="#sect4">See Also</A></LI> -<LI><A NAME="toc5" HREF="#sect5">Author</A></LI> -</UL> -</BODY></HTML> diff --git a/man/runit-halt.8 b/man/runit-halt.8 @@ -1,35 +0,0 @@ -.TH runit-halt 8 -.SH NAME -runit-halt \- stop the system -.SH SYNOPSIS -.B init -0 -.br -.B runit-halt -.SH DESCRIPTION -.B runit-halt -causes the Unix process no 1 -.BR runit (8) -to halt the system. Normally -.B runit-halt -is run by -.BR runit-init (8) -if called as -.B init 0\fR. -.P -To signal -.BR runit (8) -the system halt request, -.B runit-halt -removes the /etc/runit/reboot file and touches /etc/runit/stopit. Then a CONT -signal is sent to -.BR runit (8). -.SH EXIT CODES -.B runit-halt -always returns 0. -.SH SEE ALSO -runit-init(8), -runit(8), -runit-reboot(8) -.SH AUTHOR -Gerrit Pape <pape@smarden.org> diff --git a/man/runit-init.8 b/man/runit-init.8 @@ -19,20 +19,30 @@ or .B init 6\fR: .TP .B init 0 -run -.BR runit-halt (8) -to halt the system. +tells the Unix process no 1 to shutdown and halt the system. To signal +.BR runit (8) +the system halt request, the +.I /etc/runit/reboot +file is removed and +.I /etc/runit/stopit +is touched. Then a CONT signal is sent to +.BR runit (8). .TP .B init 6 -run -.BR runit-reboot (8) -to reboot the system. +tells the Unix process no 1 to shutdown and reboot the system. To signal +.BR runit (8) +the system reboot request, the +.I /etc/runit/reboot +and +.I /etc/runit/stopit +files are touched. Then a CONT signal is sent to +.BR runit (8). .SH EXIT CODES .B runit-init returns 111 on error, 0 in all other cases. .SH SEE ALSO -runit(8), -runit-halt(8), -runit-reboot(8) +runit(8) + +http://smarden.org/pape/runit/ .SH AUTHOR Gerrit Pape <pape@smarden.org> diff --git a/man/runit-reboot.8 b/man/runit-reboot.8 @@ -1,35 +0,0 @@ -.TH runit-reboot 8 -.SH NAME -runit-reboot \- reboot the system -.SH SYNOPSIS -.B init -6 -.br -.B runit-reboot -.SH DESCRIPTION -.B runit-reboot -causes the Unix process no 1 -.BR runit (8) -to reboot the system. Normally -.B runit-reboot -is run by -.BR runit-init (8) -if called as -.B init 6\fR. -.P -To signal -.BR runit (8) -the system reboot request, -.B runit-reboot -touches the /etc/runit/reboot and /etc/runit/stopit files. Then a CONT -signal is sent to -.BR runit (8). -.SH EXIT CODES -.B runit-reboot -always returns 0. -.SH SEE ALSO -runit-init(8), -runit(8), -runit-halt(8) -.SH AUTHOR -Gerrit Pape <pape@smarden.org> diff --git a/man/runit.8 b/man/runit.8 @@ -44,7 +44,7 @@ exists, .B runit runs .IR /etc/runit/ctrlaltdel , -waits for it to terminate and then enters Stage 3 for system shutdown. +waits for it to terminate and then sends itself a CONT signal. .SH SIGNALS .B runit only accepts signals in Stage 2. @@ -61,8 +61,8 @@ if .B runit receives an INT signal, a ctrl-alt-del keyboard request is triggered. .SH SEE ALSO -init(8), -runit-halt(8), -runit-reboot(8) +runit-init(8) + +http://smarden.org/pape/runit/ .SH AUTHOR Gerrit Pape <pape@smarden.org> diff --git a/package/CHANGES b/package/CHANGES @@ -1,3 +1,10 @@ +runit 0.2.0 +Mon, 26 Nov 2001 12:29:44 +0100 + * runit-halt, runit-reboot removed, integrated into runit-init + * tested with dietlibc + * doc: usedietlibs.html added. + * BSD license. + runit 0.1.2 Thu, 22 Nov 2001 18:29:05 +0100 * collects all terminated children in all stages diff --git a/package/commands b/package/commands @@ -1,4 +1,2 @@ runit runit-init -runit-halt -runit-reboot diff --git a/package/compile b/package/compile @@ -10,15 +10,17 @@ mkdir -p compile command test -r compile/home || echo $here > compile/home test -h compile/src || ln -s $here/src compile/src +# support, default: ../daemontools/compile +test -h src/support || ln -s ../../daemontools/compile src/support +test -d src/support || \ + ( echo 'daemontools not found.'; rm -f src/support; exit 1 ) + echo 'Linking ./src/* into ./compile...' for i in `ls src` do test -h compile/$i || ln -s src/$i compile/$i done -# support, default: ../daemontools/compile -test -h compile/support || ln -s ../../daemontools/compile compile/support - echo 'Compiling everything in ./compile...' ( cd compile; exec make ) diff --git a/package/upgrade b/package/upgrade @@ -7,9 +7,9 @@ test -d src || ( echo 'Wrong working directory.'; exit 1 ) here=`env - PATH=$PATH pwd` parent=`dirname $here` -echo 'Creating symlink runit -> runit-0.1.2...' +echo 'Creating symlink runit -> runit-0.2.0...' rm -f runit -ln -s runit-0.1.2 runit +ln -s runit-0.2.0 runit mv -f runit .. echo 'Making command links in /command...' diff --git a/src/init.c b/src/init.c @@ -1,15 +1,19 @@ #include <sys/types.h> +#include <signal.h> #include <unistd.h> #include "strerr.h" #include "pathexec.h" +#include "sig.h" +#include "open.h" +#include "error.h" #define USAGE " 0|6" #define WARNING "init: warning: " #define FATAL "init: fatal: " #define RUNIT "/sbin/runit" -#define HALT "/sbin/runit-halt" -#define REBOOT "/sbin/runit-reboot" +#define STOPIT "/etc/runit/stopit" +#define REBOOT "/etc/runit/reboot" const char *progname; @@ -17,37 +21,61 @@ void usage(void) { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); } +void runit_halt () { + if (open_trunc(STOPIT) == -1) { + strerr_die4sys(111, FATAL, "unable to create ", STOPIT, ": "); + } + if (unlink(REBOOT) == -1) { + if (errno != error_noent) { + strerr_die4sys(111, FATAL, "unable to remove ", REBOOT, ": "); + } + } + kill(1, sig_cont); + exit(0); +} +void runit_reboot () { + if (open_trunc(STOPIT) == -1) { + strerr_die4sys(111, FATAL, "unable to create ", STOPIT, ": "); + } + if (open_trunc(REBOOT) == -1) { + strerr_die4sys(111, FATAL, "unable to create ", REBOOT, ": "); + } + kill(1, sig_cont); + exit(0); +} + int main (int argc, const char * const *argv, const char * const *envp) { const char *prog[2]; progname =*argv++; - prog[1] =0; - if (getpid() == 1) { + prog[1] =0; prog[0] ="runit"; /* kernel is starting init, runit does the job. */ - pathexec_run(RUNIT, (const char* const *) prog, envp); + pathexec_run(RUNIT, (const char * const *) prog, envp); /* serious error */ strerr_die4sys(111, FATAL, "unable to start ", prog[0], ": "); } - if (! *argv) usage(); + if (! *argv || ! **argv) usage(); - if (**argv == '0') { - prog[0] =HALT; - pathexec_run(*prog, (const char* const *) prog, envp); - strerr_die4sys(111, FATAL, "unable to start ", prog[0], ": "); + switch (**argv) { + case '0': + runit_halt(); + break; + case '6': + runit_reboot(); + break; + case '-': + if ((*argv)[1] == 'V') { + strerr_warn1("$Id$\n", 0); + } + default: + usage(); } - if (**argv == '6') { - prog[0] =REBOOT; - pathexec_run(*prog, (const char* const *) prog, envp); - strerr_die4sys(111, FATAL, "unable to start ", prog[0], ": "); - } - - usage(); /* not reached */ exit(0); diff --git a/src/runit-halt b/src/runit-halt @@ -1,7 +0,0 @@ -#!/bin/sh -( cd /etc/runit -rm -f reboot -touch stopit -kill -CONT 1 -) -exit 0 diff --git a/src/runit-reboot b/src/runit-reboot @@ -1,6 +0,0 @@ -#!/bin/sh -( cd /etc/runit -touch stopit reboot -kill -CONT 1 -) -exit 0 diff --git a/src/runit.c b/src/runit.c @@ -47,6 +47,7 @@ void sig_child_handler (void) { } int main (int argc, const char * const *argv, const char * const *envp) { + const char * prog[2]; int pid, pid2; int wstat; int fd; @@ -92,7 +93,6 @@ int main (int argc, const char * const *argv, const char * const *envp) { } if (!pid) { /* child */ - const char * prog[2]; prog[0] =stage[st]; prog[1] =0; @@ -112,7 +112,7 @@ int main (int argc, const char * const *argv, const char * const *envp) { strerr_warn3(INFO, "enter stage: ", stage[st], 0); pathexec_run(*prog, (const char* const *) prog, envp); - strerr_warn3(FATAL, "could not start child: ", stage[st], &strerr_sys); + strerr_die3sys(0, FATAL, "could not start child: ", stage[st]); } x.fd =selfpipe[0]; @@ -153,7 +153,7 @@ int main (int argc, const char * const *argv, const char * const *envp) { continue; } - /* sig */ + /* sig? */ if (!sigc && !sigi) { #ifdef DEBUG strerr_warn2(WARNING, "poll: ", &strerr_sys); @@ -161,13 +161,17 @@ int main (int argc, const char * const *argv, const char * const *envp) { continue; } if (st != 1) { - strerr_warn2(WARNING, "sigs only work in stage 2.", 0); + strerr_warn2(WARNING, "signals only work in stage 2.", 0); sigc =sigi =0; continue; } - if (sigi && ((fd =open_write(CTRLALTDEL)) != -1)) { + if (sigi && ((fd =open_read(CTRLALTDEL)) != -1)) { close(fd); strerr_warn2(INFO, "ctrl-alt-del request...", 0); + + prog[0] =CTRLALTDEL; + prog[1] =0; + while ((pid2 =fork()) == -1) { strerr_warn4(FATAL, "unable to fork for \"", CTRLALTDEL, "\" pausing: ", @@ -176,14 +180,9 @@ int main (int argc, const char * const *argv, const char * const *envp) { } if (!pid2) { /* child */ - const char * prog[2]; - - prog[0] =CTRLALTDEL; - prog[1] =0; - strerr_warn3(INFO, "enter stage: ", prog[0], 0); - pathexec_run(*prog, (const char* const *) prog, envp); - strerr_warn3(FATAL, "could not start child: ", prog[0], &strerr_sys); + pathexec_run(*prog, (const char * const *) prog, envp); + strerr_die3sys(0, FATAL, "could not start child: ", prog[0]); } if (wait_pid(&wstat, pid2) == -1) { strerr_warn2(FATAL, "wait_pid: ", &strerr_sys); @@ -191,6 +190,7 @@ int main (int argc, const char * const *argv, const char * const *envp) { if (wait_crashed(wstat)) { strerr_warn3(WARNING, "child crashed: ", CTRLALTDEL, 0); } + strerr_warn3(INFO, "leave stage: ", prog[0], 0); sigi =0; sigc++; } @@ -233,6 +233,7 @@ int main (int argc, const char * const *argv, const char * const *envp) { } } sigc =0; + strerr_warn3(INFO, "leave stage: ", stage[st], 0); /* enter stage 3 */ break;