Linux Labs

Users, permissions, and processes / Stage 12 of 13

Signals and process termination

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 9 · on a machine · 4 min

The exports have to stop

What you will learn

  • End a process with the TERM signal and know how KILL differs from it.
  • Send signals to your own and other users' processes and check the result.
  • Explain why a zombie survives kill and who removes it.

Two exports are writing reports, and both have to be stopped. A colleague always stops processes with kill -9; you will try a plain kill. Compare what is left in the reports.

Exercise · look

kill and kill -9

In ~/signal-lab, run the five commands in order: start export a and stop it with a plain kill, start export b and stop it with kill -9, then read both reports. $! is the PID of the last background command.

First, predict

Both exports are stopped. What will a.txt and b.txt hold?

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
Check yourself 1 question

Why is there no saved line in b.txt?

  • kill does not work with files; it sends a signal to a process. Export b simply never wrote the saved line.

  • It did start: cat b.txt prints started, which the export writes at start. The ending is what is missing.

  • Export b wrote the started line into the file, so writing to it is allowed.

kill -9 stopped export b at once, and it never got to append the saved line.

Ubuntu 24.04
Loading…