3

I'm on Debian GNU/Linux. The man page for "kill" says I can use negative PID value to kill process group, but when running on command line, it does not work:

$ /bin/kill -9 -21581
/bin/kill: invalid option -- '2'

Usage:
 kill [options] <pid> [...]
etc.

When using the bash built-in kill, it works fine.

mehturt
  • 91
  • 1
  • 9

1 Answers1

9

Because its the first PID, you need to preceed it with "--" otherwise it'll be mistook for an option.

kill -9 -- -21581
Sirch
  • 5,697
  • 4
  • 19
  • 36
  • Is this documented anywhere? – mehturt May 17 '12 at 14:46
  • Sorry. I found it documented on RHEL, but not on Debian. – mehturt May 17 '12 at 14:54
  • @mehturt This is documented in the 'Common Options' chapter of the gnu coreutils doc [http://www.gnu.org/software/coreutils/manual/coreutils.html#toc_Common-options] – Dana the Sane Nov 13 '12 at 17:03
  • ‘--’ "--" Delimit the option list. Later arguments, if any, are treated as operands even if they begin with ‘-’. For example, ‘sort -- -r’ reads from the file named -r. – Zibri Aug 08 '19 at 16:27