mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-08 22:20:19 +01:00
dhcp: properly reap child process in nm_dhcp_client_stop_existing()
We kill the process based on the PID from the pidfile. This can be
our own child process so we must use nm_utils_kill_child_sync()
instead of nm_utils_kill_process_sync().
(cherry picked from commit c61c71a168)
This commit is contained in:
parent
fa9f7fe6e3
commit
31f06008c7
1 changed files with 11 additions and 4 deletions
|
|
@ -590,9 +590,10 @@ nm_dhcp_client_stop_existing (const char *pid_file, const char *binary_name)
|
|||
if ((errno == 0) && (tmp > 1)) {
|
||||
guint64 start_time;
|
||||
const char *exe;
|
||||
pid_t ppid;
|
||||
|
||||
/* Ensure the process is a DHCP client */
|
||||
start_time = nm_utils_get_start_time_for_pid (tmp, NULL, NULL);
|
||||
start_time = nm_utils_get_start_time_for_pid (tmp, NULL, &ppid);
|
||||
proc_path = g_strdup_printf ("/proc/%ld/cmdline", tmp);
|
||||
if ( start_time
|
||||
&& g_file_get_contents (proc_path, &proc_contents, NULL, NULL)) {
|
||||
|
|
@ -602,9 +603,15 @@ nm_dhcp_client_stop_existing (const char *pid_file, const char *binary_name)
|
|||
else
|
||||
exe = proc_contents;
|
||||
|
||||
if (!strcmp (exe, binary_name))
|
||||
nm_utils_kill_process_sync (tmp, start_time, SIGTERM, LOGD_DHCP,
|
||||
"dhcp-client", 1000 / 2, 1000 / 20, 2000);
|
||||
if (!strcmp (exe, binary_name)) {
|
||||
if (ppid == getpid ()) {
|
||||
/* the process is our own child. */
|
||||
nm_utils_kill_child_sync (tmp, SIGTERM, LOGD_DHCP, "dhcp-client", NULL, 1000 / 2, 1000 / 20);
|
||||
} else {
|
||||
nm_utils_kill_process_sync (tmp, start_time, SIGTERM, LOGD_DHCP,
|
||||
"dhcp-client", 1000 / 2, 1000 / 20, 2000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue