--- ./src/core/dhcp/nm-dhcp-client.h.orig 2022-03-06 07:02:58.000000000 -0600 +++ ./src/core/dhcp/nm-dhcp-client.h 2022-03-09 15:07:05.974017045 -0600 @@ -260,7 +260,7 @@ /* Backend helpers for subclasses */ void nm_dhcp_client_stop_existing(const char *pid_file, const char *binary_name); -void nm_dhcp_client_stop_pid(pid_t pid, const char *iface); +void nm_dhcp_client_stop_pid(pid_t pid, const char *iface, int sig); void nm_dhcp_client_start_timeout(NMDhcpClient *self); --- ./src/core/dhcp/nm-dhcp-dhcpcd.c.orig 2022-02-23 09:40:42.000000000 -0600 +++ ./src/core/dhcp/nm-dhcp-dhcpcd.c 2022-03-09 15:07:05.974017045 -0600 @@ -158,31 +158,17 @@ { NMDhcpDhcpcd *self = NM_DHCP_DHCPCD(client); pid_t pid; - int sig, errsv; + int sig; pid = nm_dhcp_client_get_pid(client); if (pid > 1) { sig = release ? SIGALRM : SIGTERM; _LOGD("sending %s to dhcpcd pid %d", sig == SIGALRM ? "SIGALRM" : "SIGTERM", pid); - /* dhcpcd-9.x features privilege separation. - * It's not our job to track all these processes so we rely on dhcpcd - * to always cleanup after itself. - * Because it also re-parents itself to PID 1, the process cannot be - * reaped or waited for. - * As such, just send the correct signal. - */ - if (kill(pid, sig) == -1) { - errsv = errno; - _LOGE("failed to kill dhcpcd %d:%s", errsv, strerror(errsv)); - } - - /* When this function exits NM expects the PID to be -1. - * This means we also need to stop watching the pid. - * If we need to know the exit status then we need to refactor NM - * to allow a non -1 to mean we're waiting to exit still. - */ + /* We need to remove the watch before stopping the process */ nm_dhcp_client_stop_watch_child(client, pid); + + nm_dhcp_client_stop_pid(pid, nm_dhcp_client_get_iface(client), sig); } } --- ./src/core/dhcp/nm-dhcp-dhclient.c.orig 2022-02-23 09:40:42.000000000 -0600 +++ ./src/core/dhcp/nm-dhcp-dhclient.c 2022-03-09 15:07:05.974017045 -0600 @@ -617,7 +617,7 @@ if (dhclient_start(client, NULL, TRUE, &rpid, NULL)) { /* Wait a few seconds for the release to happen */ - nm_dhcp_client_stop_pid(rpid, nm_dhcp_client_get_iface(client)); + nm_dhcp_client_stop_pid(rpid, nm_dhcp_client_get_iface(client), SIGTERM); } } } --- ./src/core/dhcp/nm-dhcp-client.c.orig 2022-03-06 07:02:58.000000000 -0600 +++ ./src/core/dhcp/nm-dhcp-client.c 2022-03-09 15:08:51.964019416 -0600 @@ -204,14 +204,14 @@ } void -nm_dhcp_client_stop_pid(pid_t pid, const char *iface) +nm_dhcp_client_stop_pid(pid_t pid, const char *iface, int sig) { char *name = iface ? g_strdup_printf("dhcp-client-%s", iface) : NULL; g_return_if_fail(pid > 1); nm_utils_kill_child_sync(pid, - SIGTERM, + sig, LOGD_DHCP, name ?: "dhcp-client", NULL, @@ -232,7 +232,7 @@ if (priv->pid > 0) { /* Clean up the watch handler since we're explicitly killing the daemon */ watch_cleanup(self); - nm_dhcp_client_stop_pid(priv->pid, priv->config.iface); + nm_dhcp_client_stop_pid(priv->pid, priv->config.iface, SIGTERM); } priv->pid = -1; }