2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-22 09:57:20 +00:00

[master] Add code to remove pid files and to log killing of clients

This commit is contained in:
Shawn Routhier 2014-05-07 08:03:19 -07:00
parent b6ab3f6c2a
commit f950de775f
4 changed files with 23 additions and 2 deletions

View File

@ -103,6 +103,11 @@ by Eric Young (eay@cryptsoft.com).
Thanks to Jiri Popelka at Red Hat for the bug and fix. Thanks to Jiri Popelka at Red Hat for the bug and fix.
[ISC-Bugs #21238 [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 Changes since 4.3.0rc1
- None - None

View File

@ -408,8 +408,10 @@ main(int argc, char **argv) {
e = fscanf(pidfd, "%ld\n", &temp); e = fscanf(pidfd, "%ld\n", &temp);
oldpid = (pid_t)temp; oldpid = (pid_t)temp;
if (e != 0 && e != EOF) { if (e != 0 && e != EOF && oldpid) {
if (oldpid && (kill(oldpid, SIGTERM) == 0)) { if (kill(oldpid, SIGTERM) == 0) {
log_info("Killed old client process");
(void) unlink(path_dhclient_pid);
/* /*
* wait for the old process to * wait for the old process to
* cleanly terminate. * cleanly terminate.
@ -418,6 +420,9 @@ main(int argc, char **argv) {
* the parent can be signaled... * the parent can be signaled...
*/ */
sleep(1); sleep(1);
} else if (errno == ESRCH) {
log_info("Removed stale PID file");
(void) unlink(path_dhclient_pid);
} }
} }
fclose(pidfd); fclose(pidfd);
@ -3867,6 +3872,9 @@ unsigned cons_agent_information_options (cfg_options, outpacket,
static void shutdown_exit (void *foo) 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); exit (0);
} }

View File

@ -1717,5 +1717,9 @@ dhcp_set_control_state(control_object_state_t oldstate,
control_object_state_t newstate) { control_object_state_t newstate) {
if (newstate != server_shutdown) if (newstate != server_shutdown)
return ISC_R_SUCCESS; return ISC_R_SUCCESS;
if (no_pid_file == ISC_FALSE)
(void) unlink(path_dhcrelay_pid);
exit(0); exit(0);
} }

View File

@ -1354,6 +1354,8 @@ static isc_result_t dhcp_io_shutdown_countdown (void *vlp)
free_everything (); free_everything ();
omapi_print_dmalloc_usage_by_caller (); omapi_print_dmalloc_usage_by_caller ();
#endif #endif
if (no_pid_file == ISC_FALSE)
(void) unlink(path_dhcpd_pid);
exit (0); exit (0);
} }
#else #else
@ -1363,6 +1365,8 @@ static isc_result_t dhcp_io_shutdown_countdown (void *vlp)
free_everything (); free_everything ();
omapi_print_dmalloc_usage_by_caller (); omapi_print_dmalloc_usage_by_caller ();
#endif #endif
if (no_pid_file == ISC_FALSE)
(void) unlink(path_dhcpd_pid);
exit (0); exit (0);
} }
#endif #endif