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.

1 Answer 1

9

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

kill -9 -- -21581
4
  • Is this documented anywhere?
    – mehturt
    May 17, 2012 at 14:46
  • Sorry. I found it documented on RHEL, but not on Debian.
    – mehturt
    May 17, 2012 at 14:54
  • @mehturt This is documented in the 'Common Options' chapter of the gnu coreutils doc [gnu.org/software/coreutils/manual/… Nov 13, 2012 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 8, 2019 at 16:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .