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.
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.
Why is there no saved line in b.txt?
-
killdoes not work with files; it sends a signal to a process. Export b simply never wrote the saved line. -
It did start:
cat b.txtprints 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.