:: [DNG] Bug in procps "kill"?
Página Inicial
Delete this message
Reply to this message
Autor: Steffen Dettmer
Data:  
Para: Dng
CC: Steffen Dettmer
Assunto: [DNG] Bug in procps "kill"?
Hi,

I'm tracking an issue with some automatic build system and found that:

  sdettmer@RefVm6:~/work/p1/src (master *+$|u=) $ strace -e kill /bin/kill
-7659 -7660
  kill(-7, SIGTERM)                       = -1 ESRCH (No such process)
  +++ exited with 0 +++
  sdettmer@RefVm6:~/work/p1/src (master *+$|u=) $


Instead of sending to -TERM 7, I'd expect signaling to -7659 and -7660, and
I expect kill to print out an error message if the kill call failes, such
as "kill: (-7659) - No such process", because according to man page

SYNOPSIS
       kill [options] <pid> [...]
DESCRIPTION
      ....Negative PID values may be used to choose whole process groups


I don't expect to find bugs in essential tools out in the field since
decades, so I assume I'm doing something wrong.

Am I holding it wrong?

I think I somehow misunderstand the usage, am I? Can somebody help /
explain / comment on that?

Best regards,
Steffen

ps: please don't try "kill -12345", as this may terminate the whole X
session.


$ gdb src/kill
Exec /usr/bin/gdb...
GNU gdb (Debian 13.1-3) 13.1
...
Reading symbols from src/kill...
(gdb) set args -9876
(gdb) b main
Breakpoint 1 at 0x2571: file src/kill.c, line 67.
(gdb) r
Starting program: procps-4.0.3/src/kill -9876
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, main (argc=2, argv=0x7fffffffe0f8) at src/kill.c:67
67          int exitvalue = EXIT_SUCCESS;
(gdb) n
70          bool use_sigqueue = false;
(gdb)
84          setlocale (LC_ALL, "");
(gdb)
85          bindtextdomain(PACKAGE, LOCALEDIR);
(gdb)
86          textdomain(PACKAGE);
(gdb)
89          if (argc < 2)
(gdb)
92          signo = skill_sig_option(&argc, argv);
(gdb)
93          if (signo < 0)
(gdb)
94              signo = SIGTERM;
(gdb)
96          opterr=0; /* suppress errors on -123 */
(gdb)
97          while ((i = getopt_long(argc, argv, "l::Ls:hVq:", longopts,
&optindex)) != -1)
(gdb)
98              switch (i) {
(gdb) p i
$1 = 63
(gdb) n
135                 if (!isdigit(optopt)) {
(gdb) p optopt
$2 = 57
(gdb) n
141                     pid = (long)('0' - optopt);
(gdb) p /c optopt
$3 = 57 '9'
(gdb) n
142                     if (!execute_kill((pid_t) pid, signo, use_sigqueue,
sigval))
(gdb) p pid
$4 = -9
(gdb)