14

Yes, I've seen that there's already a similar question, but I came across kill -- -0 and was wondering what -- is doing?

5
  • 3
    We do already have unix.stackexchange.com/questions/11376 .
    – JdeBP
    Dec 13, 2017 at 21:09
  • 1
    @JdeBP That post explains part of the question (the -- part), but doesn't explain -0 though Dec 14, 2017 at 0:40
  • Where did you run across this? I've never seen it before, and am curious. Thanks!
    – cxw
    Dec 14, 2017 at 1:08
  • 1
    The question isn't asking about the -0. Indeed, the question explicitly points to an existing question that covers that, too.
    – JdeBP
    Dec 14, 2017 at 6:45
  • The question asks about signal zero (what is non-existent), and not about parametrization! Not dupe!
    – peterh
    Dec 14, 2017 at 8:21

2 Answers 2

17

In UNIX/Linux world two dashes one after other mean end of options. For example if you want to search for string -n with grep you should use command like:

grep -- -n file

If you want to get only the line number in above case you should use

grep -l -- -n file

So the command kill -- -0 try to send signal to process with ID -0 (minus zero)

11
  • 12
    As for what process 0 is: "If pid equals 0, then sig is sent to every process in the process group of the calling process." (kill(2))
    – ilkkachu
    Dec 13, 2017 at 16:40
  • Just for the record PID 0 is available in some UNIX OS (like Solaris) Dec 13, 2017 at 16:44
  • As some system/kernel process, I hope? Though FWIW, POSIX has almost the same description of killing pid 0, except that it mentions unspecified system processes.
    – ilkkachu
    Dec 13, 2017 at 16:49
  • 1
    Why would one want to pass PID of minus zero? Aren't integers on all CPUs running POSIX-compatible OSes today two's complement, thus lacking any special encoding for -0?
    – Ruslan
    Dec 13, 2017 at 21:22
  • 2
    @SergiyKolodyazhnyy -0 the option will not send anything. -0 the non-option will. Hence the -- in the command here.
    – muru
    Dec 14, 2017 at 4:08
7

In this case it is used to denote that the -0 is not an option being passed in. If you were to do kill -0 it would think of -0 as an option not as the PID being passed in.

For example if you did ls -- -l it will look for a file named -l as opposed to just listing the directory in long form.

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