dhcpclient and dhcpd do not stop on sigterm

Thomas Markwalder tmark at isc.org
Tue Mar 27 13:11:54 UTC 2018


Hello Prashantkumar:

I suspect you may be running a packaged version of the software, rather than our officially released software. Unless you build from our source and define ENABLE_GENTLE_SHUTDOWN (undefined by default), neither dhcpd nor dhclient install signal handlers and will, if sent a SIGTERM promptly stop.

As you can see from the following strace of dhcpd built without ENABLE_GENTLE_SHUTDOWN (the default), the process terminates forthwith:

  
dhcpd without ENABLE_GENTLE_SHUTDOWN:
-------------------------------------------------------------------------------
tmark at cserver ~ $ sudo /usr/bin/strace -ttT -s 100 -ff -p `pgrep dhcpd`
/usr/bin/strace: Process 15129 attached
06:55:40.028953 select(22, [4 5 7 8 9], [], NULL, NULL) = ? ERESTARTNOHAND (To be restarted if no handler) <10.294941>
06:55:50.324192 --- SIGTERM {si_signo=SIGTERM, si_code=SI_USER, si_pid=15191, si_uid=0} ---
06:55:50.340149 +++ killed by SIGTERM +++
--------------------------------------------------------------------------------


Defining ENABLE_GENTLE_SHUTDOWN adds signal handlers that for dhclient will cause it to release it's address(es) and for dhcpd, IF it's part of a failover pair, to go through partner down.   Here's dhcpd strace after rebuilding with ENABLE_GENTLE_SHUTDOWN but not running as part of a failover pair:


-----------------------------------------------------------------------------
tmark at cserver ~ $ sudo /usr/bin/strace -ttT -s 100 -ff -p `pgrep dhcpd`
/usr/bin/strace: Process 14926 attached
06:53:30.163410 select(22, [4 5 7 8 9], [], NULL, NULL) = ? ERESTARTNOHAND (To be restarted if no handler) <18.171104>
06:53:48.334888 --- SIGTERM {si_signo=SIGTERM, si_code=SI_USER, si_pid=15020, si_uid=0} ---
06:53:48.334957 rt_sigreturn({mask=[]}) = -1 EINTR (Interrupted system call) <0.000014>
06:53:48.335074 sendto(3, "<182>Mar 27 06:53:48 dhcpd: Received signal 15, initiating shutdown.", 68, MSG_NOSIGNAL, NULL, 0) = 68 <0.000108>
06:53:48.335258 write(2, "Received signal 15, initiating shutdown.", 40) = 40 <0.000147>
06:53:48.335447 write(2, "\n", 1)       = 1 <0.000103>
06:53:48.335597 select(22, [4 5 7 8 9], [], NULL, {0, 0}) = 0 (Timeout) <0.000019>
06:53:48.335714 close(9)                = 0 <0.000023>
06:53:48.335789 sendto(3, "<182>Mar 27 06:53:48 dhcpd: Disabling output on LPF/enp0s10/08:00:27:c7:c6:20/178.16.1.0/24", 91, MSG_NOSIGNAL, NULL, 0) = 91 <0.000030>
06:53:48.335856 write(2, "Disabling output on LPF/enp0s10/08:00:27:c7:c6:20/178.16.1.0/24", 63) = 63 <0.000103>
06:53:48.335991 write(2, "\n", 1)       = 1 <0.000127>
06:53:48.336165 close(5)                = 0 <0.006051>
06:53:48.342269 sendto(3, "<182>Mar 27 06:53:48 dhcpd: Disabling input on LPF/enp0s10/08:00:27:c7:c6:20/178.16.1.0/24", 90, MSG_NOSIGNAL, NULL, 0) = 90 <0.000035>
06:53:48.342347 write(2, "Disabling input on LPF/enp0s10/08:00:27:c7:c6:20/178.16.1.0/24", 62) = 62 <0.000114>
06:53:48.342497 write(2, "\n", 1)       = 1 <0.000123>
06:53:48.342664 sendto(3, "<182>Mar 27 06:53:48 dhcpd: Disabling output on LPF/enp0s9/08:00:27:30:e5:6c/175.16.1.0/24", 90, MSG_NOSIGNAL, NULL, 0) = 90 <0.000064>
06:53:48.342764 write(2, "Disabling output on LPF/enp0s9/08:00:27:30:e5:6c/175.16.1.0/24", 62) = 62 <0.000110>
06:53:48.342943 write(2, "\n", 1)       = 1 <0.000091>
06:53:48.343063 close(7)                = 0 <0.016188>
06:53:48.359464 sendto(3, "<182>Mar 27 06:53:48 dhcpd: Disabling input on LPF/enp0s9/08:00:27:30:e5:6c/175.16.1.0/24", 89, MSG_NOSIGNAL, NULL, 0) = 89 <0.000124>
06:53:48.359753 write(2, "Disabling input on LPF/enp0s9/08:00:27:30:e5:6c/175.16.1.0/24", 61) = 61 <0.001290>
06:53:48.361294 write(2, "\n", 1)       = 1 <0.000565>
06:53:48.362482 unlink("output/v4.pid") = 0 <0.001224>
06:53:48.364292 exit_group(0)           = ?
06:53:48.366991 +++ exited with 0 +++
-------------------------------------------------------------------------------
                                                      
               
Please note the log message being emitted, reflecting that the signal has been received;

    06:53:48.335258 write(2, "Received signal 15, initiating shutdown.", 40) = 40 <0.000147>

And you can see from the above that does a bit more tidying up before stopping.

            
If you are not building from our released source, you may wish to try that:

     https://www.isc.org/downloads/dhcp/

otherwise, you will need to reach out to the packager.


Regards,

Thomas Markwalder
ISC Software Engineering

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20180327/723c726f/attachment.html>


More information about the dhcp-users mailing list