[Pkg-sysvinit-commits] r911 - in sysvinit/trunk/debian: .
initscripts/etc/init.d patches
Petter Reinholdtsen
pere at costa.debian.org
Mon Sep 11 19:40:05 UTC 2006
Author: pere
Date: 2006-09-11 19:40:02 +0000 (Mon, 11 Sep 2006)
New Revision: 911
Added:
sysvinit/trunk/debian/patches/82_killall_retval.dpatch
Modified:
sysvinit/trunk/debian/changelog
sysvinit/trunk/debian/initscripts/etc/init.d/sendsigs
sysvinit/trunk/debian/patches/00list
Log:
* Rewrite sendsigs to sleep up to 5 seconds (instead of always
sleeping 5 seconds) during shutdown if there are no processes left
to wait for. Modify killall5 to make it report if it found any
processes to kill to make this possible.
Modified: sysvinit/trunk/debian/changelog
===================================================================
--- sysvinit/trunk/debian/changelog 2006-09-11 19:39:04 UTC (rev 910)
+++ sysvinit/trunk/debian/changelog 2006-09-11 19:40:02 UTC (rev 911)
@@ -11,6 +11,10 @@
* New patch 68_init_quiet to make init less verbose when the 'quiet'
kernel option is used. (Closes: #326677)
* Add a few lintian overrides for things that are correct though strange.
+ * Rewrite sendsigs to sleep up to 5 seconds (instead of always
+ sleeping 5 seconds) during shutdown if there are no processes left
+ to wait for. Modify killall5 to make it report if it found any
+ processes to kill to make this possible.
-- Petter Reinholdtsen <pere at debian.org> Mon, 11 Sep 2006 00:44:44 +0200
Modified: sysvinit/trunk/debian/initscripts/etc/init.d/sendsigs
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/sendsigs 2006-09-11 19:39:04 UTC (rev 910)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/sendsigs 2006-09-11 19:40:02 UTC (rev 911)
@@ -16,11 +16,20 @@
do_stop () {
# Kill all processes.
log_action_begin_msg "Asking all remaining processes to terminate"
- killall5 -15
+ killall5 -15 # SIGTERM
log_action_end_msg 0
- sleep 5
+ for seq in 1 2 3 4 5 ; do
+ # use SIGCONT/signal 18 to check if there are
+ # processes left. No need to check the exit code
+ # value, because either killall5 work and it make
+ # sense to wait for processes to die, or it fail and
+ # there is nothing to wait for.
+ killall5 -18 || break
+
+ sleep 1
+ done
log_action_begin_msg "Killing all remaining processes"
- killall5 -9
+ killall5 -9 # SIGKILL
log_action_end_msg 0
}
Modified: sysvinit/trunk/debian/patches/00list
===================================================================
--- sysvinit/trunk/debian/patches/00list 2006-09-11 19:39:04 UTC (rev 910)
+++ sysvinit/trunk/debian/patches/00list 2006-09-11 19:40:02 UTC (rev 911)
@@ -31,5 +31,6 @@
71_wall_hostname
80_killall_sched
81_killall_avoid_init
+82_killall_retval
90_shutdown_H
91_sulogin_lockedpw
Added: sysvinit/trunk/debian/patches/82_killall_retval.dpatch
===================================================================
--- sysvinit/trunk/debian/patches/82_killall_retval.dpatch (rev 0)
+++ sysvinit/trunk/debian/patches/82_killall_retval.dpatch 2006-09-11 19:40:02 UTC (rev 911)
@@ -0,0 +1,64 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 82_killall_retval.dpatch by Petter Reinholdtsen
+
+Modify killall5 to make it report if it found any processes to kill.
+This make it possible to avoid sleeping for 5 seconds during shutdown
+if there are no processes left to wait for.
+
+ at DPATCH@
+Index: sysvinit/man/killall5.8
+===================================================================
+--- sysvinit/man/killall5.8 (revision 856)
++++ sysvinit/man/killall5.8 (working copy)
+@@ -10,6 +10,10 @@
+ kernel threads and the processes in its own session, so it won't kill
+ the shell that is running the script it was called from. Its primary
+ (only) use is in the \fBrc\fP scripts found in the /etc/init.d directory.
++.SH EXIT STATUS
++The program return zero if it killed processes. It return 2 if no
++process were killed, and 1 if it was unable to find any processes
++(/proc/ is missing).
+ .SH SEE ALSO
+ .BR halt (8),
+ .BR reboot (8)
+Index: sysvinit/src/killall5.c
+===================================================================
+--- sysvinit/src/killall5.c (revision 856)
++++ sysvinit/src/killall5.c (working copy)
+@@ -603,6 +603,9 @@
+ int pid, sid = -1;
+ int sig = SIGKILL;
+
++ /* return non-zero if no process was killed */
++ int retval = 2;
++
+ /* Get program name. */
+ if ((progname = strrchr(argv[0], '/')) == NULL)
+ progname = argv[0];
+@@ -643,15 +646,17 @@
+ /* Read /proc filesystem */
+ if (readproc(1) < 0) {
+ kill(-1, SIGCONT);
+- exit(1);
++ return(1);
+ }
+
+ /* Now kill all processes except init (pid 1) and our session. */
+ sid = (int)getsid(0);
+ pid = (int)getpid();
+ for (p = plist; p; p = p->next)
+- if (p->pid != 1 && p->pid != pid && p->sid != sid && !p->kernel)
++ if (p->pid != 1 && p->pid != pid && p->sid != sid && !p->kernel) {
+ kill(p->pid, sig);
++ retval = 0;
++ }
+
+ /* And let them continue. */
+ kill(-1, SIGCONT);
+@@ -662,5 +667,5 @@
+ /* Force the kernel to run the scheduler */
+ usleep(1);
+
+- return 0;
++ return retval;
+ }
Property changes on: sysvinit/trunk/debian/patches/82_killall_retval.dpatch
___________________________________________________________________
Name: svn:executable
+ *
More information about the Pkg-sysvinit-commits
mailing list