2017-06-27 13:18:56 +0000, Kenny McCormack:
> What does "kill 0" do?
[...]
It kills your whole process group.
At the prompt of an interactive shell, for shells that don't
have "kill" builtin "kill 0" will run the kill command in a
process group of its own so kill will just kill itself.
For shells that have "kill" builtin, for "kill 0" alone, that
will send SIGTERM to the process group of the shell, usually
only the shell process, but if your shell was started for
instance as:
(sleep 1000 & bash)
at the prompt of another interactive shell, both bash and sleep
will be in the same process group so SIGTERM will be sent to
both.
Interactive shells usually ignore SIGTERM and many other signals
in the main process which is probably why it appears to do
nothing for you.
kill -s HUP 0
would terminate the shell.
In things like:
sleep 10 | kill 0
The behaviour will depend on whether the shell runs that "kill
0" in the main process (ksh, zsh), or in another one that will
be a member of the process group for that job (bash).
--
Stephane