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 . Commented Dec 13, 2017 at 21:09
  • 1
    @JdeBP That post explains part of the question (the -- part), but doesn't explain -0 though Commented Dec 14, 2017 at 0:40
  • Where did you run across this? I've never seen it before, and am curious. Thanks! Commented 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. Commented Dec 14, 2017 at 6:45
  • The question asks about signal zero (what is non-existent), and not about parametrization! Not dupe! Commented 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)) Commented Dec 13, 2017 at 16:40
  • Just for the record PID 0 is available in some UNIX OS (like Solaris) Commented 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. Commented 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? Commented 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. Commented Dec 14, 2017 at 4:08
8

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.