Unified shutdown and init to use 3 second wait between SIGTERM and

SIGKILL. Defined this value in init.h (WAIT_BETWEEN_SIGNALS) for
easy modification.
Updated documentation to address Debian bug #375274.
This commit is contained in:
Jesse Smith 2018-10-22 21:44:39 -03:00
parent 7b1d470949
commit d27e34754a
6 changed files with 26 additions and 6 deletions

View File

@ -1,4 +1,17 @@
sysvinit (2.91) UNRELEASED; urgency=low
sysvinit (2.92) unreleased; urgency=low
[ Jesse Smith ]
* The shutdown and init commands were using different default delays between
sending processes SIGTERM and SIGKILL - they were 3 and 5 seconds, respectively.
Unified these on 3 seconds, using a new defined value in init.h.
Updated shutdown manual page to reflect the change and better explain
how -t and -n flags work.
Updated the init manual page with the new default value.
The updated documentation resolves Debian bug #375274.
sysvinit (2.91) world; urgency=low
[ Jesse Smith ]

View File

@ -184,7 +184,7 @@ otherwise request would be silently ignored.
.PP
\fBtelinit\fP can tell \fBinit\fP how long it should wait
between sending processes the SIGTERM and SIGKILL signals. The default
is 5 seconds, but this can be changed with the \fB-t\fP option.
is 3 seconds, but this can be changed with the \fB-t\fP option.
.PP
\fBtelinit -e\fP tells \fBinit\fP to change the environment
for processes it spawns.

View File

@ -100,8 +100,14 @@ will be sent to all users.
.\"}}}
.\"{{{ -t sec
.IP "\fB\-t\fP \fIsec\fP"
Tell \fBinit\fP(8) to wait \fIsec\fP seconds between sending processes the
warning and the kill signal, before changing to another runlevel.
Tell \fBinit\fP(8) to wait \fIsec\fP seconds between sending all processes the
warning (SIGTERM) and the kill signal (SIGKILL), before changing to another runlevel.
The default time, if no value is specified, between these two signals is
three seconds. Warning: when shutdown calls init to perform the shutdown (the
default behaviour), init checks to see if all processes have terminated
and will stop waiting early once its children have all terminated.
When shutdown is called with the -n flag, it waits the full time specified
(or three seconds) even if all other processes have terminated.
.\"}}}
.\"{{{ time
.IP \fItime\fP

View File

@ -133,7 +133,7 @@ int wrote_wtmp_reboot = 1; /* Set when we wrote the reboot record */
int wrote_utmp_reboot = 1; /* Set when we wrote the reboot record */
int wrote_wtmp_rlevel = 1; /* Set when we wrote the runlevel record */
int wrote_utmp_rlevel = 1; /* Set when we wrote the runlevel record */
int sltime = 5; /* Sleep time between TERM and KILL */
int sltime = WAIT_BETWEEN_SIGNALS; /* Sleep time between TERM and KILL */
char *argv0; /* First arguments; show up in ps listing */
int maxproclen; /* Maximal length of argv[0] with \0 */
struct utmp utproto; /* Only used for sizeof(utproto.ut_id) */

View File

@ -33,6 +33,7 @@
#define INITPID 1 /* pid of first process */
#define PIPE_FD 10 /* Fileno of initfifo. */
#define STATE_PIPE 11 /* used to pass state through exec */
#define WAIT_BETWEEN_SIGNALS 3 /* default time to wait between TERM and KILL */
/* Failsafe configuration */
#define MAXSPAWN 10 /* Max times respawned in.. */

View File

@ -348,7 +348,7 @@ void fastdown()
/* Kill all processes. */
fprintf(stderr, "shutdown: sending all processes the TERM signal...\r\n");
kill(-1, SIGTERM);
sleep(sltime ? atoi(sltime) : 3);
sleep(sltime ? atoi(sltime) : WAIT_BETWEEN_SIGNALS);
fprintf(stderr, "shutdown: sending all processes the KILL signal.\r\n");
(void) kill(-1, SIGKILL);