| Summary: | shutdown doesn't behave as described in its man page | ||
|---|---|---|---|
| Product: | Gentoo Linux | Reporter: | Arthur Hartwig <arthur.hartwig> |
| Component: | [OLD] Core system | Assignee: | Gentoo's Team for Core System packages <base-system> |
| Status: | RESOLVED NEEDINFO | ||
| Severity: | normal | CC: | zarhan |
| Priority: | High | ||
| Version: | unspecified | ||
| Hardware: | x86 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Package list: | Runtime testing required: | --- | |
| Bug Depends on: | |||
| Bug Blocks: | 103183 | ||
| Attachments: | fix garbage in man's messages | ||
|
Description
Arthur Hartwig
2005-05-29 19:39:59 UTC
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); |