Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 103183 - Shutdown procedure does not wait long enough for SIGTERMs effects, goes to KILL immediately
Summary: Shutdown procedure does not wait long enough for SIGTERMs effects, goes to KI...
Status: RESOLVED NEEDINFO
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on: 94443
Blocks:
  Show dependency tree
 
Reported: 2005-08-20 13:58 UTC by Antti Mäkelä
Modified: 2008-01-15 08:32 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Mäkelä 2005-08-20 13:58:33 UTC
When shutting down the computer (via shutdown -h now, for example), the
procedure immediately after sending TERM signal sends the KILL signal, and does
not even give time for the applications to close gracefully. This can be seen in
several different situations, like when shutting down a computer middle of an
emerge, the emerge does not have enough time to clean itself up and save
information for --resume. Similar situations arise when an administrator
remotely reboots the machine and user has, say KDE session open - KDE never gets
to shut down properly and save the user's desktop status (which would allow the
user continue where he left off with a minimal hassle after the reboot).

Proposed fixes:

Allow a longer grace period (5-10 seconds) between signals.

OR

When the shutdown procedure starts, send (only) TERM signal.
Complete the shutdown as far as possible.
As a last thing before poweroff/reboot, send another TERM, followed by a KILL.

This issue has also been seen in Bug 41877.
Comment 1 SpanKY gentoo-dev 2005-08-20 19:14:32 UTC
this has been covered in bugzilla before ... iirc, the display is incorrect
while the actual behavior is correct
Comment 2 Antti Mäkelä 2005-08-20 23:52:03 UTC
It does not seem to be correct, because several applications (like I said, KDE
and emerge itself) do not exit gracefully, but instead just die without saving
their status. Just for the record, at least emerge DOES save its status when
TERM is received, so the problem is not with the application.

Take a look for this for example:
~ # emerge -av joe

These are the packages that I would merge, in order:

Calculating dependencies ...done!
[ebuild  N    ] app-editors/joe-3.0-r2  303 kB

Total size of downloads: 303 kB

Do you want me to merge these packages? [Yes/No] y
>>> emerge (1 of 1) app-editors/joe-3.0-r2 to /
>>> Downloading http://130.230.54.100/gentoo/distfiles/joe-3.0.tar.gz
--09:47:57--  http://130.230.54.100/gentoo/distfiles/joe-3.0.tar.gz
           => `/usr/portage/distfiles/joe-3.0.tar.gz'
Connecting to 130.230.54.100:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 310,584 [application/x-tar]

100%[====================================>] 310,584      163.67K/s

09:47:59 (163.27 KB/s) - `/usr/portage/distfiles/joe-3.0.tar.gz' saved
[310,584/310,584]

>>> md5 files   ;-) joe-3.0-r2.ebuild
>>> md5 files   ;-) joe-3.1-r1.ebuild
>>> md5 files   ;-) joe-3.2.ebuild
>>> md5 files   ;-) files/digest-joe-3.0-r2
>>> md5 files   ;-) files/digest-joe-3.1-r1
>>> md5 files   ;-) files/digest-joe-3.2
>>> md5 files   ;-) files/joe-3.0-overflow.patch
>>> md5 files   ;-) files/joe-3.1-overflow.patch
>>> md5 src_uri ;-) joe-3.0.tar.gz
>>> Unpacking source...
>>> Unpacking joe-3.0.tar.gz to /var/tmp/portage/joe-3.0-r2/work
 * Applying joe-3.0-overflow.patch ...                                    [ ok ]
 * Using GNU config files from /usr/share/libtool
 *   Updating config.sub                                                  [ ok ]
 *   Updating config.guess                                                [ ok ]
>>> Source unpacked.
[kill 29805 - the emerge process, in other window]
[about 3 seconds of pause and stuff going to HDD]
Exiting due to signal
~ # emerge --resume
*** Resuming merge...
>>> emerge (1 of 1) app-editors/joe-3.0-r2 to /
....

When shutting down, the KILL goes of far too quickly.
Comment 3 SpanKY gentoo-dev 2005-08-21 00:04:15 UTC

*** This bug has been marked as a duplicate of 94443 ***
Comment 4 SpanKY gentoo-dev 2005-08-21 00:05:36 UTC
mmm maybe not a dupe but related
Comment 5 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2008-01-15 08:32:48 UTC
shutdown uses TERM, waits 3 or specified seconds, then KILL.

The code in the present shutdown has:
305     /* First idle init. */
306     if (kill(1, SIGTSTP) < 0) {
307         fprintf(stderr, "shutdown: can't idle init.\r\n");
308         exit(1);
309     }
310
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);

If you think it should be longer than 3 seconds, please reopen this bug. 3 seconds is enough time for my systems.