commit b6c38414785056cd609f2c0e796a347c5fd70ce6
parent 5f9d6e0fec4c34a1a2d6d0f451639ccc710a80d7
Author: Gerrit Pape <pape@smarden.org>
Date: Tue, 29 Jan 2002 18:56:36 +0000
0.3.0.
many changes, see package/CHANGES.
Diffstat:
20 files changed, 223 insertions(+), 106 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,6 +1,6 @@
DESTDIR=
-PACKAGE=runit-0.2.7
+PACKAGE=runit-0.3.0
DIRS=doc man etc package src
MANPAGES=man/runit.8 man/runit-init.8 man/svwaitdown.8 man/svwaitup.8
DAEMONTOOLS_PD=daemontools-pd-0.76
diff --git a/debian/changelog b/debian/changelog
@@ -1,3 +1,9 @@
+runit (0.3.0-1) woody; urgency=low
+
+ * See /package/admin/runit/package/CHANGES.
+
+ -- Gerrit Pape <pape@smarden.org> Tue, 29 Jan 2002 19:54:06 +0100
+
runit (0.2.7-1) woody; urgency=low
* See /package/admin/runit/package/CHANGES.
diff --git a/debian/postinst b/debian/postinst
@@ -25,7 +25,7 @@ set -e
case "$1" in
configure)
( \
- cd /package/admin/runit-0.2.7
+ cd /package/admin/runit-0.3.0
package/upgrade
)
;;
diff --git a/debian/rules b/debian/rules
@@ -23,22 +23,22 @@ build-stamp:
# $(MAKE)
#/usr/bin/docbook-to-man debian/runit.sgml > runit.1
- tar xfzvp runit-0.2.7.tar.gz
- mkdir -p admin/runit-0.2.7/compile
+ tar xfzvp runit-0.3.0.tar.gz
+ mkdir -p admin/runit-0.3.0/compile
tar xfzvp daemontools-pd-0.76.tar.gz \
- -C admin/runit-0.2.7/compile
+ -C admin/runit-0.3.0/compile
( \
- cd admin/runit-0.2.7/compile ; \
+ cd admin/runit-0.3.0/compile ; \
ln -s daemontools-pd-0.76 support ; \
echo 'diet gcc -O2 -Wall' > support/conf-cc ; \
echo 'diet gcc -s -Os -pipe' > support/conf-ld ; \
)
( \
- cd admin/runit-0.2.7 ; \
+ cd admin/runit-0.3.0 ; \
package/compile ; \
- echo "/package/admin/runit-0.2.7" > compile/home ; \
+ echo "/package/admin/runit-0.3.0" > compile/home ; \
rm -f compile/src ; \
- ln -s /package/admin/runit-0.2.7/src compile/src ; \
+ ln -s /package/admin/runit-0.3.0/src compile/src ; \
)
touch build-stamp
@@ -65,40 +65,40 @@ install: build
chmod 1755 debian/runit/package
cp -a admin debian/runit/package/
- rm -rf debian/runit/package/admin/runit-0.2.7/compile
- cp -a debian/runit/package/admin/runit-0.2.7/man .
- rm -rf debian/runit/package/admin/runit-0.2.7/man
- cp -a debian/runit/package/admin/runit-0.2.7/doc .
- rm -rf debian/runit/package/admin/runit-0.2.7/doc
- cp -a debian/runit/package/admin/runit-0.2.7/etc .
- rm -rf debian/runit/package/admin/runit-0.2.7/etc
- cp -a debian/runit/package/admin/runit-0.2.7/package .
+ rm -rf debian/runit/package/admin/runit-0.3.0/compile
+ cp -a debian/runit/package/admin/runit-0.3.0/man .
+ rm -rf debian/runit/package/admin/runit-0.3.0/man
+ cp -a debian/runit/package/admin/runit-0.3.0/doc .
+ rm -rf debian/runit/package/admin/runit-0.3.0/doc
+ cp -a debian/runit/package/admin/runit-0.3.0/etc .
+ rm -rf debian/runit/package/admin/runit-0.3.0/etc
+ cp -a debian/runit/package/admin/runit-0.3.0/package .
# /etc/runit
- cp -p admin/runit-0.2.7/etc/debian/[123] \
+ cp -p admin/runit-0.3.0/etc/debian/[123] \
debian/runit/etc/runit/
- cp -p admin/runit-0.2.7/etc/debian/ctrlaltdel \
+ cp -p admin/runit-0.3.0/etc/debian/ctrlaltdel \
debian/runit/etc/runit/
- cp -p admin/runit-0.2.7/etc/debian/getty-tty5/run \
+ cp -p admin/runit-0.3.0/etc/debian/getty-tty5/run \
debian/runit/etc/runit/getty-tty5
# runit programs
- cp -p debian/runit/package/admin/runit-0.2.7/command/runit* \
+ cp -p debian/runit/package/admin/runit-0.3.0/command/runit* \
debian/runit/sbin/
# cleanup
- rm -rf debian/runit/package/admin/runit-0.2.7/compile
+ rm -rf debian/runit/package/admin/runit-0.3.0/compile
# create debian/links
rm -f debian/links
for i in \
- `cat debian/runit/package/admin/runit-0.2.7/package/commands` ; \
+ `cat debian/runit/package/admin/runit-0.3.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.2.7/package/commands` ; \
+# `cat debian/runit/package/admin/runit-0.3.0/package/commands` ; \
# do \
# echo "/command/$$i /usr/local/bin/$$i" \
# >> debian/links ; \
diff --git a/doc/index.html b/doc/index.html
@@ -25,12 +25,11 @@ Dependencies and runlevels</a>
<a href="http://cr.yp.to/daemontools.html">daemontools</a> package to create
a replacement for
<a href="ftp://ftp.cistron.nl/pub/people/miquels/sysvinit/">sysvinit</a>.
-<i>runit</i> currently runs on
-<a href="http://www.debian.org/">Debian GNU/Linux sid/woody</a>,
-<a href="http://www.openbsd.org/">OpenBSD 2.9</a>,
-<a href="http://www.freebsd.org/">FreeBSD 4.4</a> and can easily be
-adapted to other unix operating systems. If <i>runit</i> runs for
-you on any other operating system or linux distribution, please let me know.
+<i>runit</i> runs on <b>Debian GNU/Linux sid/woody</b>,
+<b>OpenBSD 2.9</b>, <b>FreeBSD 4.4</b>. <i>runit</i> reportedly runs on
+<b>FreeBSD 4.3</b>, and can easily be adapted to other unix operating
+systems. If <i>runit</i> runs for you on any other operating system or
+linux distribution, please let me know.
<p>
<b>Warning:</b> Replacing <i>sysvinit</i> or <i>init</i> can cause the
system's boot to fail. Make sure you are able to recover and repair your
@@ -48,13 +47,16 @@ if this is started by the kernel.
<li><b>Stage 1:</b><br>
<i>runit</i> starts <tt>/etc/runit/1</tt> and waits for it to
terminate. The system's one time initialization tasks are done here.
+ <tt>/etc/runit/1</tt> has full control of <tt>/dev/console</tt> to be
+ able to start an emergency shell if the one time initialization tasks
+ fail.
<li><b>Stage 2:</b><br>
<i>runit</i> starts <tt>/etc/runit/2</tt> which should not return
until the system is going to halt or reboot, if it crashes, it will be
restarted. Normally, <tt>/etc/runit/2</tt> runs
<a href="http://cr.yp.to/daemontools/svscanboot.html">svscanboot</a>.
In Stage 2 <i>runit</i> optionally handles an INT signal
- (ctrl-alt-del keyboard request on i386).
+ (ctrl-alt-del keyboard request on Linux/i386).
<li><b>Stage 3:</b><br>
If <i>runit</i> is told to halt or reboot the system, or the Stage 2
returns without errors, it terminates Stage 2 if it is running and runs
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.2.7.tar.gz">runit-0.2.7.tar.gz</a> into <tt>/package</tt>
+<a href="runit-0.3.0.tar.gz">runit-0.3.0.tar.gz</a> into <tt>/package</tt>
and unpack the archive
<pre>
# cd /package
- # gunzip runit-0.2.7.tar
- # tar -xpf runit-0.2.7.tar
- # rm runit-0.2.7.tar
- # cd admin/runit-0.2.7
+ # gunzip runit-0.3.0.tar
+ # tar -xpf runit-0.3.0.tar
+ # rm runit-0.3.0.tar
+ # cd admin/runit-0.3.0
</pre>
Compile and install the <i>runit</i> programs
<pre>
diff --git a/doc/replaceinit.html b/doc/replaceinit.html
@@ -107,7 +107,7 @@ default Unix process no 1 <i>runit</i>.
</pre>
To report success:
<pre>
- # ( uname -a ; cat /etc/runit/[123] ) | mail pape-runit-0.2.7@smarden.org
+ # ( uname -a ; cat /etc/runit/[123] ) | mail pape-runit-0.3.0@smarden.org
</pre>
<hr>
@@ -187,7 +187,7 @@ Use <b>init 6</b> to reboot and <b>init 0</b> to halt a system that runs
<p>
To report success:
<pre>
- # ( uname -a ; cat /etc/runit/[123] ) | mail pape-runit-0.2.7@smarden.org
+ # ( uname -a ; cat /etc/runit/[123] ) | mail pape-runit-0.3.0@smarden.org
</pre>
<h3>Step 5: Service migration</h3>
The goal is to migrate all services from <i>/etc/rc.*</i> scheme to the
diff --git a/doc/runit.8.html b/doc/runit.8.html
@@ -18,31 +18,34 @@ as Unix process no 1. It performs the system's booting, running, and shutdown
in three Stages:
<H2><A NAME="sect3">Stage 1</A></H2>
<B>runit</B> runs <I>/etc/runit/1</I> and waits for it to terminate.
-The system's one time tasks are done here.
+The system's one time tasks are done here. <I>/etc/runit/1</I> has full control
+of <I>/dev/console</I> to be able to start an emergency shell if the one time
+initialization tasks fail. If <I>/etc/runit/1</I> itself crashes, <B>runit</B> will skip
+stage 2 and enter stage 3.
<H2><A NAME="sect4">Stage 2</A></H2>
-<B>runit</B> runs <I>/etc/runit/2</I>,
-which should not return until system shutdown; if it crashes, it will be
-restarted. Normally <I>/etc/runit/2</I> starts <B><I>svscanboot</B>(8)</I>. <B>runit</B> is able to handle
-the ctrl-alt-del keyboard request in Stage 2, see below.
+<B>runit</B> runs <I>/etc/runit/2</I>, which should
+not return until system shutdown; if it crashes, it will be restarted. Normally
+<I>/etc/runit/2</I> starts <B><I>svscanboot</B>(8)</I>. <B>runit</B> is able to handle the ctrl-alt-del
+keyboard request in Stage 2, see below.
<H2><A NAME="sect5">Stage 3</A></H2>
-If <B>runit</B> is
-told to shutdown the system, or the Stage 2 returns without errors, it
-terminates Stage 2 if it is running, and runs <I>/etc/runit/3</I>. The systems
-tasks to shutdown and halt or reboot are done here. Normally in Stage 3
-<I>/etc/runit/3</I> checks for the file <I>/etc/runit/reboot</I>. If it exists, the system
-is rebooted, it is halted otherwise.
+If <B>runit</B> is told to shutdown
+the system, or the Stage 2 returns without errors, it terminates Stage
+2 if it is running, and runs <I>/etc/runit/3</I>. The systems tasks to shutdown
+and halt or reboot are done here. Normally in Stage 3 <I>/etc/runit/3</I> checks
+for the file <I>/etc/runit/reboot</I>. If it exists, the system is rebooted, it
+is halted otherwise.
<H2><A NAME="sect6">Ctrl-alt-del</A></H2>
-If <B>runit</B> receives the ctrl-alt-del
-keyboard request and the file <I>/etc/runit/ctrlaltdel</I> exists, <B>runit</B> runs
-<I>/etc/runit/ctrlaltdel</I>, waits for it to terminate and then sends itself
-a CONT signal.
+If <B>runit</B> receives the ctrl-alt-del keyboard
+request and the file <I>/etc/runit/ctrlaltdel</I> exists, <B>runit</B> runs <I>/etc/runit/ctrlaltdel</I>,
+waits for it to terminate and then sends itself a CONT signal.
<H2><A NAME="sect7">Signals</A></H2>
-<B>runit</B> only accepts signals in Stage 2. <P>
-If <B>runit</B> receives
-a CONT signal and the file <I>/etc/runit/stopit</I> exists, <B>runit</B> is told to shutdown
-the system. <P>
-if <B>runit</B> receives an INT signal, a ctrl-alt-del keyboard request
-is triggered.
+<B>runit</B>
+only accepts signals in Stage 2. <P>
+If <B>runit</B> receives a CONT signal and the
+file <I>/etc/runit/stopit</I> exists, <B>runit</B> is told to shutdown the system. <P>
+if
+<B>runit</B> receives an INT signal, a ctrl-alt-del keyboard request is triggered.
+
<H2><A NAME="sect8">See Also</A></H2>
<I>runit-init(8)</I>, <I>svwaitdown(8)</I>, <I>svwaitup(8)</I> <P>
<I>http://smarden.org/runit/</I>
diff --git a/doc/runscripts.html b/doc/runscripts.html
@@ -13,9 +13,12 @@
<a href="#getty">getty</a><br>
<a href="#sshd">sshd</a><br>
<a href="#klogd">klogd</a><br>
+<a href="#expireproctitle">expireproctitle</a><br>
<a href="#dhcpd">dhcpd</a><br>
<a href="#dhclient">dhclient</a><br>
-<a href="#gdm">gdm</a>
+<a href="#gdm">gdm</a><br>
+<a href="#statd">statd</a>, <a href="#mountd">mountd</a><br>
+<a href="#squid">squid</a>
<hr>
This is a collection of <tt>run</tt> scripts for popular services to have
them monitored by the
@@ -54,12 +57,19 @@ The <tt>sshd</tt> program is version <tt>OpenSSH_2.9p2</tt>.
exec /sbin/klogd -n
</pre>
<hr>
+<h3><a name="expireproctitle">An <tt>expireproctitle</tt> run script</a></h3>
+<pre>
+ #!/bin/sh
+ echo -n .
+ exec sleep 300
+</pre>
+<hr>
<h3><a name="dhcpd">A <tt>dhcpd</tt> run script</a></h3>
<i>(Debian woody)</i>
<pre>
#!/bin/sh
exec 2>&1
- exec dhcpd-2.2.x -d -f
+ exec dhcpd-2.2.x -f -d -cf ./config eth0
</pre>
This service needs a
<a href="http://cr.yp.to/daemontools/faq/create.html#runlog">log service</a>
@@ -69,16 +79,56 @@ to be set up.
<i>(Debian woody)</i>
<pre>
#!/bin/sh
- exec dhclient -d eth0
+ exec dhclient -e -d -cf ./config -lf ./leases -pf ./pid eth1
</pre>
<hr>
-<h3><a name="gdm">A <tt>gdm</tt> run script</a></h4>
+<h3><a name="gdm">A <tt>gdm</tt> run script</a></h3>
<i>(Debian woody)</i>
<pre>
#!/bin/sh
exec gdm -nodaemon
</pre>
<hr>
+<h3><a name="statd">A <tt>statd</tt> run script</a></h3>
+<i>(Debian woody)</i>
+<pre>
+ #!/bin/sh
+ exec 2>&1
+ NEED_LOCKD=yes
+ if test -f /proc/ksyms; then
+ # We need to be conservative and run lockd,
+ # unless we can prove that it isn't required.
+ grep -q lockdctl /proc/ksyms || NEED_LOCKD=no
+ fi
+ if [ "$NEED_LOCKD" = yes ]; then
+ /sbin/rpc.lockd
+ fi
+ exec rpc.statd -F -d
+</pre>
+This service needs a
+<a href="http://cr.yp.to/daemontools/faq/create.html#runlog">log service</a>
+to be set up.
+<h3><a name="mountd">A <tt>mountd</tt> run script</a></h3>
+<i>(Debian woody)</i>
+<pre>
+ #!/bin/sh
+ svwaitup /service/statd
+ RPCNFSDCOUNT=8 # Number of servers to be started up by default
+ RPCMOUNTDOPTS=-F
+ exportfs -r
+ rpc.nfsd -- $RPCNFSDCOUNT
+ rpcinfo -u localhost nfs 3 >/dev/null 2>&1 ||
+ RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 3"
+ exec rpc.mountd $RPCMOUNTDOPTS
+</pre>
+<hr>
+<h3><a name="squid">A <tt>squid</tt> run script</a></h3>
+<i>(Debian woody)</i>
+<pre>
+ #!/bin/sh
+ exec squid -f ./config -sN
+</pre>
+<hr>
<address><a href="mailto:pape@smarden.org">
Gerrit Pape <pape@smarden.org>
</a></address>
diff --git a/etc/freebsd/1 b/etc/freebsd/1
@@ -1,7 +1,10 @@
#!/bin/sh
# system one time tasks
-rm -f /etc/runit/stopit
-/bin/sh /etc/rc autoboot
+/bin/sh /etc/rc autoboot && exit 0
-exit 0
+# /etc/rc crashed, start emergency shell.
+echo '/etc/rc failed. Press <enter> for emergency shell...'
+read input
+/bin/sh -p
+exec /sbin/reboot
diff --git a/etc/freebsd/3 b/etc/freebsd/3
@@ -1,19 +1,21 @@
#!/bin/sh
+PATH=/bin:/sbin:/command
echo 'Stopping services...'
-/command/svc -d /service/*
-/command/svwaitdown -t350 /service/* || \
- ( echo 'Killing services...' ; /command/svc -k /service/* )
+svc -d /service/*
+svwaitdown -t350 /service/* || ( echo 'Killing services...' ; \
+ svc -k /service/* ; svwaitdown /service/* )
echo 'Stopping log services...'
-/command/svc -d /service/*/log
-/command/svwaitdown -t35 /service/*/log
+svc -d /service/*/log
+svwaitdown -t35 /service/*/log || ( echo 'Killing log services...' ; \
+ svc -k /service/*/log ; svwaitdown /service/*/log )
echo 'Shutdown...'
if test -r /etc/runit/reboot; then
- /sbin/reboot
+ exec reboot
else
- /sbin/halt
+ exec halt
fi
exit 0
diff --git a/etc/openbsd/1 b/etc/openbsd/1
@@ -1,7 +1,10 @@
#!/bin/sh
# system one time tasks
-rm -f /etc/runit/stopit
-/bin/sh /etc/rc autoboot
+/bin/sh /etc/rc autoboot && exit 0
-exit 0
+# /etc/rc crashed, start emergency shell.
+echo '/etc/rc failed. Press <enter> for emergency shell...'
+read input
+/bin/sh -l
+exec /sbin/reboot
diff --git a/etc/openbsd/3 b/etc/openbsd/3
@@ -1,24 +1,26 @@
#!/bin/sh
+PATH=/bin:/sbin:/command
echo 'Stopping getties...'
-/command/svc -d /service/getty-*
-/command/svwaitdown -t14 /service/getty-* || \
- ( echo 'Killing getties...' ; /command/svc -k /service/getty-* )
+svc -d /service/getty-*
+svwaitdown -t14 /service/getty-* || ( echo 'Killing getties...' ; \
+ svc -k /service/getty-* ; svwaitdown /service/getty-* )
echo 'Stopping services...'
-/command/svc -d /service/*
-/command/svwaitdown -t350 /service/* || \
- ( echo 'Killing services...' ; /command/svc -k /service/* )
+svc -d /service/*
+svwaitdown -t350 /service/* || ( echo 'Killing services...' ; \
+ svc -k /service/* ; svwaitdown /service/* )
echo 'Stopping log services...'
-/command/svc -d /service/*/log
-/command/svwaitdown -t35 /service/*/log
+svc -d /service/*/log
+svwaitdown -t35 /service/*/log || ( echo 'Killing log services...' ; \
+ svc -k /service/*/log ; svwaitdown /service/*/log )
echo 'Shutdown...'
if test -r /etc/runit/reboot; then
- /sbin/reboot
+ exec reboot
else
- /sbin/halt
+ exec halt
fi
exit 0
diff --git a/man/runit.8 b/man/runit.8
@@ -12,6 +12,15 @@ booting, running, and shutdown in three Stages:
runs
.I /etc/runit/1
and waits for it to terminate. The system's one time tasks are done here.
+.I /etc/runit/1
+has full control of
+.I /dev/console
+to be able to start an emergency shell if the one time initialization tasks
+fail. If
+.I /etc/runit/1
+itself crashes,
+.B runit
+will skip stage 2 and enter stage 3.
.SH STAGE 2
.B runit
runs
diff --git a/package/CHANGES b/package/CHANGES
@@ -1,3 +1,18 @@
+runit 0.3.0
+Tue, 29 Jan 2002 19:38:33 +0100
+ * doc: adapted.
+ * runit.8: changes documented.
+ * runscripts.html: more examples.
+
+runit 0.2.9
+Thu, 17 Jan 2002 19:00:44 +0100
+ * reportedly runs on FreeBSD 4.3 (thx clemensF)
+ * svwaitdown: max timeout is 6000, really. (thx ska)
+ * runit.c: stage 1 gets no new session and full control of console; an
+ emergency shell or login program (if present) can be executed.
+ * openbsd, freebsd: support for 'single user' emergency shell in stage 1
+ * runit.c: skip stage 2 if stage 1 crashes.
+
runit 0.2.7
Tue, 1 Jan 2002 16:20:14 +0100
* tested on fresh freebsd 4.4 installation in vmware
diff --git a/package/COPYING b/package/COPYING
@@ -1,4 +1,4 @@
-Copyright (c) 2001, Gerrit Pape
+Copyright (c) 2001-2002, Gerrit Pape
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/package/README b/package/README
@@ -1,3 +1,3 @@
-Copyright 2001
+Copyright 2001-2002
G. Pape
http://smarden.org/runit/
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.2.7...'
+echo 'Creating symlink runit -> runit-0.3.0...'
rm -f runit
-ln -s runit-0.2.7 runit
+ln -s runit-0.3.0 runit
mv -f runit ..
echo 'Making command links in /command...'
diff --git a/src/runit.c b/src/runit.c
@@ -6,6 +6,7 @@
#include <sys/ioctl.h>
#include <signal.h>
#include <unistd.h>
+#include <fcntl.h>
#include "sig.h"
#include "strerr.h"
@@ -77,10 +78,11 @@ int main (int argc, const char * const *argv, const char * const *envp) {
/* console */
if ((ttyfd =open_write("/dev/console")) != -1) {
if (ioctl(ttyfd, TIOCSCTTY, (char *)NULL) != -1) {
- dup2(ttyfd, 0); dup2(ttyfd, 1); dup2(ttyfd, 2);
- if (ttyfd > 2)
- close(ttyfd);
+ strerr_warn2(WARNING, "ioctl: ", &strerr_sys);
}
+ dup2(ttyfd, 0); dup2(ttyfd, 1); dup2(ttyfd, 2);
+ if (ttyfd > 2)
+ close(ttyfd);
}
/* create selfpipe */
@@ -118,7 +120,19 @@ int main (int argc, const char * const *argv, const char * const *envp) {
prog[0] =stage[st];
prog[1] =0;
- setsid();
+ /* stage 1 gets full control of console */
+ if (st == 0) {
+ if ((ttyfd =open("/dev/console", O_RDWR)) != -1) {
+ dup2(ttyfd, 0);
+ if (ttyfd > 2)
+ close(ttyfd);
+ }
+ else
+ strerr_warn2(WARNING, "unable to open /dev/console: ", &strerr_sys);
+ }
+ else {
+ setsid();
+ }
sig_unblock(sig_alarm);
sig_unblock(sig_child);
@@ -151,10 +165,26 @@ int main (int argc, const char * const *argv, const char * const *envp) {
sig_block(sig_int);
read(selfpipe[0], &ch, 1);
-
- if ((child =wait_nohang(&wstat)) == pid) {
+
+ child =wait_nohang(&wstat);
+
+ /* reget stderr */
+ if ((ttyfd =open_write("/dev/console")) != -1) {
+ dup2(ttyfd, 2);
+ if (ttyfd > 2)
+ close(ttyfd);
+ }
+
+ if (child == pid) {
if (wait_crashed(wstat)) {
strerr_warn3(WARNING, "child crashed: ", stage[st], 0);
+ if (st == 0) {
+ /* this is stage 1 */
+ strerr_warn3(INFO, "leave stage: ", stage[st], 0);
+ strerr_warn2(WARNING, "skipping stage 2...", 0);
+ st++;
+ break;
+ }
if (st == 1) {
/* this is stage 2 */
strerr_warn2(WARNING, "killing all processes in stage 2...", 0);
@@ -181,14 +211,6 @@ int main (int argc, const char * const *argv, const char * const *envp) {
#endif
continue;
}
- /* console */
- if ((ttyfd =open_write("/dev/console")) != -1) {
- if (ioctl(ttyfd, TIOCSCTTY, (char *)NULL) != -1) {
- dup2(ttyfd, 0); dup2(ttyfd, 1); dup2(ttyfd, 2);
- if (ttyfd > 2)
- close(ttyfd);
- }
- }
if (st != 1) {
strerr_warn2(WARNING, "signals only work in stage 2.", 0);
sigc =sigi =0;
diff --git a/src/svwaitdown.c b/src/svwaitdown.c
@@ -22,7 +22,7 @@
const char *progname;
const char * const *dir;
-unsigned int rc;
+unsigned int rc =0;
void usage () {
strerr_die4x(1, "usage: ", progname, USAGE, "\n");
@@ -51,7 +51,7 @@ int main (int argc, const char * const *argv) {
switch(opt) {
case 't':
scan_ulong(optarg, &sec);
- if ((sec < 2) || (sec > 600)) {
+ if ((sec < 2) || (sec > 6000)) {
usage();
}
break;