From: Shawn Routhier Date: Wed, 7 May 2014 15:03:19 +0000 (-0700) Subject: [master] Add code to remove pid files and to log killing of clients X-Git-Tag: v4_3_1b1~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f950de775f0adad5098ecda673dcdbd76dbeff46;p=thirdparty%2Fdhcp.git [master] Add code to remove pid files and to log killing of clients --- diff --git a/RELNOTES b/RELNOTES index e8aa5be4f..c5b4ccf43 100644 --- a/RELNOTES +++ b/RELNOTES @@ -103,6 +103,11 @@ by Eric Young (eay@cryptsoft.com). Thanks to Jiri Popelka at Red Hat for the bug and fix. [ISC-Bugs #21238 +- Add a log entry when killing a client and remove the PID files + when a server, relay or client are killed. + [ISC-Bugs #16970] + [ISC-Bugs #17258] + Changes since 4.3.0rc1 - None diff --git a/client/dhclient.c b/client/dhclient.c index 5f6ed00f3..df87a93d1 100644 --- a/client/dhclient.c +++ b/client/dhclient.c @@ -408,8 +408,10 @@ main(int argc, char **argv) { e = fscanf(pidfd, "%ld\n", &temp); oldpid = (pid_t)temp; - if (e != 0 && e != EOF) { - if (oldpid && (kill(oldpid, SIGTERM) == 0)) { + if (e != 0 && e != EOF && oldpid) { + if (kill(oldpid, SIGTERM) == 0) { + log_info("Killed old client process"); + (void) unlink(path_dhclient_pid); /* * wait for the old process to * cleanly terminate. @@ -418,6 +420,9 @@ main(int argc, char **argv) { * the parent can be signaled... */ sleep(1); + } else if (errno == ESRCH) { + log_info("Removed stale PID file"); + (void) unlink(path_dhclient_pid); } } fclose(pidfd); @@ -3867,6 +3872,9 @@ unsigned cons_agent_information_options (cfg_options, outpacket, static void shutdown_exit (void *foo) { + /* get rid of the pid if we can */ + if (no_pid_file == ISC_FALSE) + (void) unlink(path_dhclient_pid); exit (0); } diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c index ccb9768b8..11751d212 100644 --- a/relay/dhcrelay.c +++ b/relay/dhcrelay.c @@ -1717,5 +1717,9 @@ dhcp_set_control_state(control_object_state_t oldstate, control_object_state_t newstate) { if (newstate != server_shutdown) return ISC_R_SUCCESS; + + if (no_pid_file == ISC_FALSE) + (void) unlink(path_dhcrelay_pid); + exit(0); } diff --git a/server/dhcpd.c b/server/dhcpd.c index 2ae031e6f..28cc56292 100644 --- a/server/dhcpd.c +++ b/server/dhcpd.c @@ -1354,6 +1354,8 @@ static isc_result_t dhcp_io_shutdown_countdown (void *vlp) free_everything (); omapi_print_dmalloc_usage_by_caller (); #endif + if (no_pid_file == ISC_FALSE) + (void) unlink(path_dhcpd_pid); exit (0); } #else @@ -1363,6 +1365,8 @@ static isc_result_t dhcp_io_shutdown_countdown (void *vlp) free_everything (); omapi_print_dmalloc_usage_by_caller (); #endif + if (no_pid_file == ISC_FALSE) + (void) unlink(path_dhcpd_pid); exit (0); } #endif