[lsb-discuss] restart behavior (initscript)

Jim Knoble jmknoble+lsb-discuss at pobox.com
Thu Aug 7 08:03:59 PDT 2003

Circa 2003-08-06 22:09:20 -0500 dixit Mark Hatle:

: This is my interpretation of the spec.. so it very well may be wrong.
: Ademar de Souza Reis Jr. wrote:
: > (i) The daemon (sshd in my case) is misconfigured, so
: >     after stopping it, it will not (re)start.
: >
: >     Can I check for the presence of this scenario and refuse
: >     to stop the service in the first place?
: I'd consider this an undefined situation, however my feeling would be a 
: stop followed by an aborted start.  The end result is the daemon has 
: been stopped and an error message/status code sent to the user.

I don't see why a restart shouldn't be atomic, i.e., all-or-nothing,
especially for important system services like sshd.

: >(ii) When the daemon (sshd again) receives a SIGHUP, it spawns a
: >     new copy of itself and kills the old parent process, but the
: >     childs are kept alive.
: >
: >     Since there's a new parent process (the one who accepts
: >     new connections), can I consider this the same of a
: >     restart?
: This would be the "reload" case.  It is my interpretation that a restart 
: must do exactly that.  Stop the current daemon, and fully restart it. 
: The restart is useful if the physical binary changes, while a reload is 
: useful if the configuration changes.

For what it's worth, in the case of OpenSSH's sshd (www.openssh.com),
as well as a similar case for the Exim MTA (www.exim.org), sending
SIGHUP causes the daemon to re-exec itself at the path it was started
from.  That is, in pseudocode:

    variable saved_arguments

    main(argc, argv) {
        saved_arguments = argv
    on_receiving_sighup() {
        execv(saved_arguments[0], saved_arguments)

This does in fact fully restart the binary, it merely avoids closing
down child processes (which, in the case of sshd, could be a really bad
thing if you're managing the system from an SSH connection).

jim knoble  |  jmknoble+lsb-discuss at pobox.com
(GnuPG fingerprint: 31C4:8AAC:F24E:A70C:4000::BBF4:289F:EAA8:1381:1491)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 256 bytes
Desc: not available
Url : http://lists.linux-foundation.org/pipermail/lsb-discuss/attachments/20030807/beec5296/attachment.pgp 

More information about the lsb-discuss mailing list