[Pkg-sysvinit-commits] r1063 - in sysvinit/trunk/debian: . patches
pere at alioth.debian.org
pere at alioth.debian.org
Sun Nov 18 23:08:31 UTC 2007
Author: pere
Date: 2007-11-18 23:08:31 +0000 (Sun, 18 Nov 2007)
New Revision: 1063
Added:
sysvinit/trunk/debian/patches/82_killall_exclude_pids.dpatch
Modified:
sysvinit/trunk/debian/changelog
sysvinit/trunk/debian/patches/00list
Log:
* New patch 82_killall_exclude_pids.dpatch adding new option -o
to killall5, to omit killing the pid given on the command line.
Based on patch from Ubuntu.
Modified: sysvinit/trunk/debian/changelog
===================================================================
--- sysvinit/trunk/debian/changelog 2007-11-18 22:54:20 UTC (rev 1062)
+++ sysvinit/trunk/debian/changelog 2007-11-18 23:08:31 UTC (rev 1063)
@@ -9,6 +9,9 @@
from Ubuntu.
* Rename 20_pidof.dpatch to 80_killall_pidof.dpatch, to group the
killall5 patches together.
+ * New patch 82_killall_exclude_pids.dpatch adding new option -o
+ to killall5, to omit killing the pid given on the command line.
+ Based on patch from Ubuntu.
-- Petter Reinholdtsen <pere at debian.org> Tue, 30 Jan 2007 23:14:04 +0100
Modified: sysvinit/trunk/debian/patches/00list
===================================================================
--- sysvinit/trunk/debian/patches/00list 2007-11-18 22:54:20 UTC (rev 1062)
+++ sysvinit/trunk/debian/patches/00list 2007-11-18 23:08:31 UTC (rev 1063)
@@ -31,5 +31,6 @@
80_killall_sched
81_killall_avoid_init
82_killall_retval
+82_killall_exclude_pids
90_shutdown_H
91_sulogin_lockedpw
Added: sysvinit/trunk/debian/patches/82_killall_exclude_pids.dpatch
===================================================================
--- sysvinit/trunk/debian/patches/82_killall_exclude_pids.dpatch (rev 0)
+++ sysvinit/trunk/debian/patches/82_killall_exclude_pids.dpatch 2007-11-18 23:08:31 UTC (rev 1063)
@@ -0,0 +1,115 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 82_killall_exclude_pids.dpatch by Colin Watson <cjwatson at ubuntu.com>
+## Modified for Debian by Petter Reinholdtsen <pere at hungry.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Implement '-o omitpid' option, to allow sendsigs to avoid killing
+## DP: processes that are e.g. implementing the root filesystem.
+
+ at DPATCH@
+diff -urNad sysvinit-2.86.ds1~/man/killall5.8 sysvinit-2.86.ds1/man/killall5.8
+--- sysvinit-2.86.ds1~/man/killall5.8 2004-06-09 13:47:45.000000000 +0100
++++ sysvinit-2.86.ds1/man/killall5.8 2007-08-06 13:39:29.000000000 +0100
+@@ -4,12 +4,19 @@
+ .SH SYNOPSIS
+ .B killall5
+ .RB -signalnumber
++.RB [ \-o
++.IR omitpid ]
++.RB [ \-o
++.IR omitpid.. ]
+ .SH DESCRIPTION
+ .B killall5
+ is the SystemV killall command. It sends a signal to all processes except
+ 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 OPTIONS
++.IP "-o \fIomitpid\fP"
++Tells \fIkillall5\fP to omit processes with that process id.
+ .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
+diff -urNad sysvinit-2.86.ds1~/src/killall5.c sysvinit-2.86.ds1/src/killall5.c
+--- sysvinit-2.86.ds1~/src/killall5.c 2007-08-06 13:39:28.000000000 +0100
++++ sysvinit-2.86.ds1/src/killall5.c 2007-08-06 13:39:29.000000000 +0100
+@@ -596,11 +596,15 @@
+
+
+
++#define KILLALL_OMITSZ 16
++
+ /* Main for either killall or pidof. */
+ int main(int argc, char **argv)
+ {
+ PROC *p;
+ int pid, sid = -1;
++ pid_t opid[KILLALL_OMITSZ];
++ int i, oind, omit = 0;
+ int sig = SIGKILL;
+
+ /* Get program name. */
+@@ -617,10 +621,34 @@
+ return main_pidof(argc, argv);
+
+ /* Right, so we are "killall". */
++ for (oind = KILLALL_OMITSZ-1; oind > 0; oind--)
++ opid[oind] = 0;
++
+ if (argc > 1) {
+- if (argc != 2) usage();
+- if (argv[1][0] == '-') (argv[1])++;
+- if ((sig = atoi(argv[1])) <= 0 || sig > 31) usage();
++ for (i = 1; i < argc; i++) {
++ if (argv[i][0] == '-') (argv[i])++;
++ if (argv[i][0] == 'o') {
++ if (++i >= argc) usage();
++ if (oind >= KILLALL_OMITSZ -1) {
++ nsyslog(LOG_ERR,"omit pid buffer size "
++ "%d exceeded!\n",
++ KILLALL_OMITSZ);
++ closelog();
++ exit(1);
++ }
++ if ((opid[oind] = atoi(argv[i])) < 1) {
++ nsyslog(LOG_ERR,
++ "illegal omit pid value "
++ "(%s)!\n", argv[i]);
++ closelog();
++ exit(1);
++ }
++ oind++;
++ omit = 1;
++ }
++ else if ((sig = atoi(argv[1])) <= 0 || sig > 31)
++ usage();
++ }
+ }
+
+ /* First get the /proc filesystem online. */
+@@ -649,11 +677,20 @@
+ /* 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) {
+- kill(p->pid, sig);
+- retval = 0;
+- }
++ for (p = plist; p; p = p->next) {
++ if (p->pid == 1 || p->pid == pid || p->sid == sid || p->kernel)
++ continue;
++ if (omit) {
++ for (i = 0; i < oind; i++)
++ if (opid[i] == p->pid)
++ break;
++ /* On a match, continue with the for loop above. */
++ if (i < oind)
++ continue;
++ }
++ kill(p->pid, sig);
++ retval = 0;
++ }
+
+ /* And let them continue. */
+ kill(-1, SIGCONT);
Property changes on: sysvinit/trunk/debian/patches/82_killall_exclude_pids.dpatch
___________________________________________________________________
Name: svn:executable
+ *
More information about the Pkg-sysvinit-commits
mailing list