Linux Labs

Users, permissions, and processes / Stage 12 of 13

Signals and process termination

Not running Starting usually ~20 s
Leave the lesson

Step 5 of 9 · on a machine · 8 min

A process you cannot kill

Some process rows are not removed even by kill -9, and they carry a STAT letter you have not met in earlier lessons. Look at such a row and try to remove it with the KILL signal.

Exercise · look

A Z row and kill -9

In ~/zombie-lab, run three commands: the rows of the spooler program, kill -9 on the process from zombie.pid, and its row again. $(cat zombie.pid) puts the file's contents, a process number, into the command.

First, predict

What will the last command show after kill -9?

Now start the exercise, run the command and compare your prediction with the output.

Sign in and start The machine is available after signing in

Z means zombie. The process has already exited: its program no longer runs, and its memory is freed. What is left in the process table is a row with the exit status, which the parent has to collect. You did the same in the shell: wait got the exit status of a background job.

Until the parent collects the status, the row hangs on. A signal will not help: there is nobody to receive it, so kill -9 reported success while the row stayed. If the parent exits, its zombies pass to systemd, PID 1, which collects their statuses right away.

One zombie is harmless: it takes neither CPU nor memory. The trouble is a parent that does not collect statuses, so zombies pile up. That is why you deal with the parent: find the program by PPID and see whether it can collect the statuses on request. Ending the parent is a last resort, since its work stops along with it.

Check yourself 1 question

A Z row hangs in ps, and its parent is a working program. What will remove the row?

  • The Z row is an entry in the process table, not tied to the program file. The parent removes it by collecting the code.

  • The row hangs while the parent lives and has not collected the code. The parent collects it, or systemd once the parent is gone.

  • A zombie has already exited, and a signal does nothing to it: in the exercise the Z row stayed in place after kill -9.

A zombie has already exited and waits for its parent to collect the exit status. So you deal with the parent: find it by PPID and see whether it can collect the code without exiting.

Ubuntu 24.04
Loading…