>_ IzzyLab

Hands-on task

This task is step 22 of the course “Processes and signals”

A zombie under a queue worker

hard~10 min

Two identical queue-worker processes are running on the server, one for the mail queue and one for sms. Monitoring has spotted a zombie in the process table: a child process has already exited, but one of the workers never collected its exit code.

Write the PID of the zombie's parent (just the number) to /root/reaper.txt and get rid of the zombie. The healthy worker must keep running.

What you'll practise:
  • ps -eo
  • zombies
  • STAT/defunct
  • ppid
  • kill by PID

Topic breakdown

When a process exits, the kernel keeps its exit code and a minimal entry in the process table until the parent collects the result by calling wait(). Until then the process is a zombie: it doesn't run and doesn't use memory, but it holds a table entry and a PID. Signals have no effect on a zombie; there's nothing left to kill. There are two ways it goes away: the parent calls wait(), or the parent exits and the zombie passes to PID 1 (in a container that's an init like tini), which reaps such entries automatically. So you don't hunt the zombie, you hunt its parent, via the PPID field. Lots of zombies point to a bug in the parent program: the PID table is finite, and sooner or later new processes will fail to start.

What's checked

  1. reaper.txt holds the PID of the zombie's parent
  2. no zombie is left in the process table
  3. the healthy worker keeps running

What it looks like