Yes, I've seen that there's already a similar question, but I came across kill -- -0
and was wondering what --
is doing?
2 Answers
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)
-
12
-
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.– ilkkachuDec 13, 2017 at 16:49
-
1Why 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
?– RuslanDec 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.– muruDec 14, 2017 at 4:08
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.
--
part), but doesn't explain-0
though-0
. Indeed, the question explicitly points to an existing question that covers that, too.