In your case you have two processes involved:
- Your shell.
- The
man
process that you put into background.
How exactly the kill
command works depends on your shell, but, in most cases, it is a shell builtin, which, basically, simply invokes the kill(2)
syscall. As you read in the man page, 0
is a special value that means “send the signal to all processes in the current process group”. So, when you type kill 0
you send SIGTERM
(which is the default signal) to all processes in the current process group.
Now, the real question here is: what is the current process group? Long story short, process groups are used by shells to control shell pipelines (things like /bin/echo hello | /usr/bin/wc -c
). When your shell runs a new command, it will create a new process group for the processes that a part of this command (e.g. in my example above it will create a proces group with two processes: echo
and wc
).
So, in your example, the shell will create a new process group for the man
process that it starts (and all its children), you can see it by running:
$ ps -o pid,ppid,pgid,comm
(PPID is the parent PID, PGID is the process group).
And then you type kill 0
in your shell, which is in a process group of its own (remember, it created a new process group for man
). So all that happens is SIGTERM
is delivered to all processes in your shell’s process group, which is only the shell itself (and it ignores the SIGTERM
).