Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Dec 1999 15:48:18 GMT
From:      m.seaman@inpharmatica.co.uk
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/15496: killall(1) limited to 16 character process names by procfs(5) 
Message-ID:  <199912151548.PAA64079@b0.farm.inpharmatica.co.uk>

next in thread | raw e-mail | index | archive | help

>Number:         15496
>Category:       bin
>Synopsis:       killall(1) limited to 16 character process names by procfs(5)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Dec 15 07:50:00 PST 1999
>Closed-Date:
>Last-Modified:
>Originator:     Matthew Seaman
>Release:        FreeBSD 3.4-RC alpha
>Organization:
Inpharmatica Ltd
>Environment:

	FreeBSD 3.4-RC 

b0:/tmp:% uname -a 
FreeBSD b0.farm.inpharmatica.co.uk 3.4-RC FreeBSD 3.4-RC #0: Tue Dec 14 13:02:41 GMT 1999     root@b0.farm.inpharmatica.co.uk:/usr/src/sys/compile/FARM  alpha

>Description:

	killall(1) reads procfs /proc/${pid}/status entries to find
the process names the user wants to kill.  However, only the first 16
(MAXCOMLEN from /usr/include/sys/param.h) characters of the process
name are available.  Trying naively to killall(1) a process with a
longer name is guarranteed to fail: instead the supplied name should
be truncated to the first 16 characters.

	I'm not convinced that modifying procfs() to fix this somewhat
obscure case is really going to be worthwhile.  This should certainly
be documented though.

>How-To-Repeat:

b0:/tmp:% cat foo.c
#include <unistd.h>

int
main (int argc, char *argv[])
{
        sleep(600);
}
b0:/tmp:% cc -o 1234567890123 foo.c 
b0:/tmp:% cp 1234567890123{,4}
b0:/tmp:% cp 1234567890123{,45}
b0:/tmp:% cp 1234567890123{,456}
b0:/tmp:% cp 1234567890123{,4567}
b0:/tmp:% ./12345678901234 & 
[4] 63828
b0:/tmp:% ./12345678901235 &
[5] 63829
b0:/tmp:% ./123456789012345 &
[6] 63830
b0:/tmp:% ./1234567890123456 &
[7] 63831
b0:/tmp:% ./12345678901234567 &
[8] 63832
b0:/tmp:% head /proc/{63826,63828,63830,63831,63832}/status
==> /proc/63826/status <==
1234567890123 63826 63513 63826 63513 5,2 ctty 945270683,3518 0,1030 0,6184 nanslp 1000 1000 1000,1000,1000,0,999,1018,994,993,997

==> /proc/63828/status <==
12345678901234 63828 63513 63828 63513 5,2 ctty 945270704,936540 0,909 0,6369 nanslp 1000 1000 1000,1000,1000,0,999,1018,994,993,997

==> /proc/63830/status <==
123456789012345 63830 63513 63830 63513 5,2 ctty 945270715,716412 0,3262 0,4349 nanslp 1000 1000 1000,1000,1000,0,999,1018,994,993,997

==> /proc/63831/status <==
1234567890123456 63831 63513 63831 63513 5,2 ctty 945270719,857664 0,1879 0,5639 nanslp 1000 1000 1000,1000,1000,0,999,1018,994,993,997

==> /proc/63832/status <==
1234567890123456 63832 63513 63832 63513 5,2 ctty 945270723,443053 0,2114 0,5287 nanslp 1000 1000 1000,1000,1000,0,999,1018,994,993,997
b0:/tmp:% killall 12345678901234567
No processes matching ``12345678901234567''


>Fix:
	
--- killall.1	Tue Aug 31 10:08:27 1999
+++ /tmp/killall.1	Wed Dec 15 15:16:38 1999
@@ -52,6 +52,10 @@
 .Nm
 that match the name
 .Ar procname .
+Only the first 16 characters of the process name are available from
+.Xr procfs 5
+for comparison: process names specified on the command line must be
+truncated to this limit in order to match successfully.
 The super-user is allowed to kill any process.
 .Pp
 The options are as follows:



>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199912151548.PAA64079>