[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#253099: marked as done (killall.sh: Can kill wrong PID)

Your message dated Tue, 15 Jun 2004 18:02:05 -0400
with message-id <E1BaM0L-00027N-00@newraff.debian.org>
and subject line Bug#253099: fixed in netcfg 0.69
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

Received: (at submit) by bugs.debian.org; 7 Jun 2004 08:48:34 +0000
>From jdthood@aglu.demon.nl Mon Jun 07 01:48:34 2004
Return-path: <jdthood@aglu.demon.nl>
Received: from post-21.mail.nl.demon.net [] 
	by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1BXFo2-0000Yh-00; Mon, 07 Jun 2004 01:48:34 -0700
Received: from [] (helo=localhost)
	by post-21.mail.nl.demon.net with esmtp (Exim 3.36 #2)
	id 1BXFo1-000PJk-00; Mon, 07 Jun 2004 08:48:33 +0000
Received: by localhost (Postfix, from userid 1001)
	id 5B8A110D6EE; Mon,  7 Jun 2004 10:48:32 +0200 (CEST)
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
From: Thomas Hood <jdthood@yahoo.co.uk>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: killall.sh: Can kill wrong PID
X-Mailer: reportbug 2.61
Date: Mon, 07 Jun 2004 10:48:32 +0200
Message-Id: <[🔎] 20040607084832.5B8A110D6EE@localhost>
Delivered-To: submit@bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2004_03_25 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Status: No, hits=-8.0 required=4.0 tests=BAYES_00,HAS_PACKAGE 
	autolearn=no version=2.60-bugs.debian.org_2004_03_25

Package: netcfg
Version: 0.67
Severity: minor
Tags: patch

The killall.sh script uses the following code to find the PIDs of running
DHCP client daemons:

pids=$(ps ax | grep 'udhcpc\|dhclient\|pump' | sed 's/^[

However, (1) this picks up the PID of the grep process itself:

$ ps ax | grep 'udhcpc\|dhclient\|pump'
15769 pts/2    S+     0:00 grep udhcpc\|dhclient\|pump

(2) I don't see where udhcpc is started.  In dhcp.c only
dhclient3, dhclient and pump seem to be supported.

(3) ps has built in output formatting so sed isn't really needed.

Better would be:

for CLIENT in dhclient3 dhclient pump ; do
  pids=$(ps --no-headers -o pid -C $CLIENT)
  for pid in $pids; do

Here's a patch:

--- /tmp/killall.sh_ORIG	2004-06-07 10:24:26.000000000 +0200
+++ killall.sh	2004-06-07 10:26:34.000000000 +0200
@@ -1,15 +1,15 @@
 # Killall for dhcp clients.
-pids=$(ps ax | grep 'udhcpc\|dhclient\|pump' | sed 's/^[ ]*\([0-9]*\).*/\1/')
-for pid in $pids; do
-  if kill -0 $pid 2>/dev/null; then
-    kill -TERM $pid
-    sleep 1
-    # Still alive? Die!
+for CLIENT in dhclient3 dhclient pump ; do
+  for pid in $(ps --no-headers -o pid -C $CLIENT) ; do
     if kill -0 $pid 2>/dev/null; then
-      kill -KILL $pid
+      kill -TERM $pid
+      sleep 1
+      # Still alive? Die!
+      if kill -0 $pid 2>/dev/null; then
+        kill -KILL $pid
+      fi
-  fi
+  done

Another thing: One second isn't very long.  What happens if this code
kill -KILL's the DHCP client before it has finished deconfiguring the
interface?  Perhaps start-stop-daemon should be used here with a
longer timeout.

for CLIENT in /sbin/dhclient3 /sbin/dhclient /sbin/pump ; do
  [ -x $CLIENT ] && start-stop-daemon --stop --quiet --oknodo --exec $CLIENT --retry=TERM/10/KILL/2 > /dev/null

This has the additional advantage of only killing genuine processes,
not processes whose executable files happen to have the same names.

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (900, 'unstable'), (700, 'testing'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.4.25
Locale: LANG=en_IE@euro, LC_CTYPE=en_IE@euro

Received: (at 253099-close) by bugs.debian.org; 15 Jun 2004 22:08:24 +0000
>From katie@ftp-master.debian.org Tue Jun 15 15:08:24 2004
Return-path: <katie@ftp-master.debian.org>
Received: from newraff.debian.org [] (mail)
	by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1BaM6S-0003El-00; Tue, 15 Jun 2004 15:08:24 -0700
Received: from katie by newraff.debian.org with local (Exim 3.35 1 (Debian))
	id 1BaM0L-00027N-00; Tue, 15 Jun 2004 18:02:05 -0400
From: Joshua Kwan <joshk@triplehelix.org>
To: 253099-close@bugs.debian.org
X-Katie: $Revision: 1.49 $
Subject: Bug#253099: fixed in netcfg 0.69
Message-Id: <E1BaM0L-00027N-00@newraff.debian.org>
Sender: Archive Administrator <katie@ftp-master.debian.org>
Date: Tue, 15 Jun 2004 18:02:05 -0400
Delivered-To: 253099-close@bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2004_03_25 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Status: No, hits=-6.0 required=4.0 tests=BAYES_00,HAS_BUG_NUMBER 
	autolearn=no version=2.60-bugs.debian.org_2004_03_25
X-CrossAssassin-Score: 4

Source: netcfg
Source-Version: 0.69

We believe that the bug you reported is fixed in the latest version of
netcfg, which is due to be installed in the Debian FTP archive:

  to pool/main/n/netcfg/netcfg-dhcp_0.69_i386.udeb
  to pool/main/n/netcfg/netcfg-static_0.69_i386.udeb
  to pool/main/n/netcfg/netcfg_0.69.dsc
  to pool/main/n/netcfg/netcfg_0.69.tar.gz
  to pool/main/n/netcfg/netcfg_0.69_i386.udeb

A summary of the changes between this version and the previous one is

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 253099@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
Joshua Kwan <joshk@triplehelix.org> (supplier of updated netcfg package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)

Hash: SHA1

Format: 1.7
Date: Tue, 15 Jun 2004 14:34:25 -0700
Source: netcfg
Binary: netcfg-static netcfg-dhcp netcfg
Architecture: source i386
Version: 0.69
Distribution: unstable
Urgency: medium
Maintainer: Debian Install System Team <debian-boot@lists.debian.org>
Changed-By: Joshua Kwan <joshk@triplehelix.org>
 netcfg     - Configure the network (udeb)
 netcfg-dhcp - Configure the network via DHCP (udeb)
 netcfg-static - Configure a static network (udeb)
Closes: 247734 248147 253086 253099 253361
 netcfg (0.69) unstable; urgency=medium
   * Sylvain Ferriol
     - fix error message during plip config. (Closes: #253361)
   * Christian Perrier
     - Remove trailing exclamation mark from netcfg/dhcp_success_note
     - Run debconf-updatepo and unfuzzy templates for removed exclamation mark
   * Joshua Kwan
     - Corrected reference to the pppconfig package. (Closes: #253086)
     - killall.sh: add grep -v grep (Closes: #253099)
     - Allow netcfg/disable_dhcp option that governs what use_dhcp is
       set to every time we start, instead of hardcoding true. Defaults
       to true, so default behavior has not changed. (Closes: #248147)
     - Fix /etc/hosts writing after much deliberation. (Closes: #247734)
     - Use a static buffer for mii-diag call.
     - Sleep for 1.5 seconds before mii-diag, because slow network cards
       just take that long to answer. And for those that take more that's
       just too bad.
   * Bastian Blank
     - Readd postinst files for netcfg-dhcp and netcfg-static.
   * Updated translations:
     - Bosnian (bs.po) by Safir Å eÄ?eroviÄ?
     - German (de.po) by Alwin Meschede
     - Hebrew (he.po) by Lior Kaplan
     - Polish (pl.po) by Bartosz Fenski
 1f4f445b201837e09519996e6f984d59 1526 debian-installer optional netcfg_0.69.dsc
 0f6c26fd1e22e49cdfd8598c37807a4c 164920 debian-installer optional netcfg_0.69.tar.gz
 00aba0fcc8c332b467e2d6dd9b93ea9a 133408 debian-installer optional netcfg_0.69_i386.udeb
 b45a912313f920d8883f11958178eea9 102358 debian-installer optional netcfg-dhcp_0.69_i386.udeb
 6aa768786cb1473f0a7e9a97a71e41c5 109560 debian-installer optional netcfg-static_0.69_i386.udeb
package-type: udeb

Version: GnuPG v1.2.4 (GNU/Linux)
Comment: http://triplehelix.org/~joshk/pubkey_gpg.asc


Reply to: