Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 94443 - shutdown doesn't behave as described in its man page
Summary: shutdown doesn't behave as described in its man page
Status: RESOLVED NEEDINFO
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 103183
  Show dependency tree
 
Reported: 2005-05-29 19:39 UTC by Arthur Hartwig
Modified: 2008-01-15 08:29 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
fix garbage in man's messages (man-1.6a-messages.patch,4.32 KB, patch)
2005-12-30 13:18 UTC, Evgeniy Dushistov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arthur Hartwig 2005-05-29 19:39:59 UTC
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:
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2005-05-29 23:59:43 UTC
Uhm, I don
Comment 2 Jakub Moc (RETIRED) gentoo-dev 2005-05-29 23:59:43 UTC
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.
Comment 3 Jakub Moc (RETIRED) gentoo-dev 2005-05-30 00:01:54 UTC
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."
Comment 4 Arthur Hartwig 2005-05-30 17:21:15 UTC
(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? 
 
Comment 5 SpanKY gentoo-dev 2005-08-21 00:04:16 UTC
*** Bug 103183 has been marked as a duplicate of this bug. ***
Comment 6 Evgeniy Dushistov 2005-12-30 13:18:27 UTC
Created attachment 75816 [details, diff]
fix garbage in man's messages
Comment 7 SpanKY gentoo-dev 2005-12-31 00:07:06 UTC
Comment on attachment 75816 [details, diff]
fix garbage in man's messages

uhh that patch has nothing to do with this bug report
Comment 8 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2008-01-15 08:29:45 UTC
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);