I observed this in sysvinit 2.85 The shutdown man page (description section) says "All processes are first notified that the system is going down by the signal SIGTERM." Shutdown sends SIGTERM to all processes only if the -n option is given. Perhaps shutdown assumes init will send the SIGTERM signal if shutdown calls init. This interpretation is suggested by the the int man page where it says "When init is requested to change the runlevel, it sends the warning signal SIGTERM to all processes that are undefined in the new runlevel." but to read on in the same paragraph suggests that init sends SIGTERM only to those processes (and their descendants) it originally created. I'm not sure if the documentation is correct or the man page. Either way, the program should behave as described in the man page. Reproducible: Always Steps to Reproduce: 1. 2. 3. Actual Results: Expected Results:
Uhm, I don
Uhm, I don´t know which man page are you reading, but I read: All processes are first notified that the system is going down by the signal SIGTERM and also -n [DEPRECATED] Don't call init(8) to do the shutdown but do it ourself. The use of this option is discouraged, and its results are not always what you'd expect. I´d suggest that you should upgrade your man-pages.
Err, the first quote from man page should be more verbose: "All processes are first notified that the system is going down by the signal SIGTERM. This gives programs like vi(1) the time to save the file being edited, mail and news processing programs a chance to exit cleanly, etc. shutdown does its job by signalling the init process, asking it to change the runlevel."
(In reply to comment #2) > Err, the first quote from man page should be more verbose: > > "All processes are first notified that the system is going down by the signal > SIGTERM. This gives programs like vi(1) the time to save the file being edited, > mail and news processing programs a chance to exit cleanly, etc. shutdown does > its job by signalling the init process, asking it to change the runlevel." (In reply to comment #2) > Err, the first quote from man page should be more verbose: > > "All processes are first notified that the system is going down by the signal > SIGTERM. This gives programs like vi(1) the time to save the file being edited, > mail and news processing programs a chance to exit cleanly, etc. shutdown does > its job by signalling the init process, asking it to change the runlevel." OK, I'll restate the bug report. A colleague reports to me that a process is not getting the SIGTERM signal when the system shuts down. The shutdown man page says shutdown sends all processes a SIGTERM signal. I wrote a short program to sleep forever but catch a SIGTERM signal with the signal handler printing a message to say it caught the signal and then exit. I ran this program and used kill to send it a SIGTERM signal and verify that the signal is caught, the message printed and the program exited. I reran this program on the console and then issued the command "shutdown -r now" but I didn't see the message from my program to say it caught the SIGTERM. Then I looked in the shutdown code and saw that, contrary to the man page, shutdown sends SIGTERM to all processes ONLY if the "-n" option is given. Is the man page correct and the shutdown code wrong or is the man page incorrect and the shutdown code correct?
*** Bug 103183 has been marked as a duplicate of this bug. ***
Created attachment 75816 [details, diff] fix garbage in man's messages
Comment on attachment 75816 [details, diff] fix garbage in man's messages uhh that patch has nothing to do with this bug report
I think this applied more to old versions of shutdown. The code in the present shutdown has: 311 /* Kill all processes. */ 312 fprintf(stderr, "shutdown: sending all processes the TERM signal...\r\n"); 313 kill(-1, SIGTERM); 314 sleep(sltime ? atoi(sltime) : 3); 315 fprintf(stderr, "shutdown: sending all processes the KILL signal.\r\n"); 316 (void) kill(-1, SIGKILL);