2008-07-27 Dan Williams <dcbw@redhat.com>

* src/dnsmasq-manager/nm-dnsmasq-manager.c
	  src/nm-device.c
	  src/ppp-manager/nm-ppp-manager.c
		- Ensure child process gets reaped.  The child watch function may be
			removed from the mainloop before the child gets killed, so we have
			to make sure the child is reaped when it's told to die intentionally



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3857 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2008-07-27 19:42:54 +00:00
parent 5ddab8fa89
commit 65d5338384
4 changed files with 30 additions and 19 deletions

View file

@ -1,3 +1,12 @@
2008-07-27 Dan Williams <dcbw@redhat.com>
* src/dnsmasq-manager/nm-dnsmasq-manager.c
src/nm-device.c
src/ppp-manager/nm-ppp-manager.c
- Ensure child process gets reaped. The child watch function may be
removed from the mainloop before the child gets killed, so we have
to make sure the child is reaped when it's told to die intentionally
2008-07-27 Dan Williams <dcbw@redhat.com>
Patch from Roy Marples <roy@marples.name>

View file

@ -357,7 +357,6 @@ nm_dnsmasq_manager_start (NMDnsMasqManager *manager,
NMDnsMasqManagerPrivate *priv;
NMCmdLine *dm_cmd;
char *cmd_str;
GSource *dm_watch;
g_return_val_if_fail (NM_IS_DNSMASQ_MANAGER (manager), FALSE);
if (error)
@ -389,11 +388,7 @@ nm_dnsmasq_manager_start (NMDnsMasqManager *manager,
nm_debug ("dnsmasq started with pid %d", priv->pid);
dm_watch = g_child_watch_source_new (priv->pid);
g_source_set_callback (dm_watch, (GSourceFunc) dm_watch_cb, manager, NULL);
g_source_attach (dm_watch, NULL);
priv->dm_watch_id = g_source_get_id (dm_watch);
g_source_unref (dm_watch);
priv->dm_watch_id = g_child_watch_add (priv->pid, (GChildWatchFunc) dm_watch_cb, manager);
out:
if (dm_cmd)
@ -410,6 +405,9 @@ ensure_killed (gpointer data)
if (kill (pid, 0) == 0)
kill (pid, SIGKILL);
/* ensure child is reaped */
waitpid (pid, NULL, WNOHANG);
return FALSE;
}
@ -433,6 +431,8 @@ nm_dnsmasq_manager_stop (NMDnsMasqManager *manager)
else
kill (priv->pid, SIGKILL);
/* ensure child is reaped */
waitpid (priv->pid, NULL, WNOHANG);
priv->pid = 0;
}

View file

@ -551,16 +551,18 @@ aipd_cleanup (NMDevice *self)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
if (priv->aipd_pid > 0) {
kill (priv->aipd_pid, SIGKILL);
priv->aipd_pid = -1;
}
if (priv->aipd_watch) {
g_source_remove (priv->aipd_watch);
priv->aipd_watch = 0;
}
if (priv->aipd_pid > 0) {
kill (priv->aipd_pid, SIGKILL);
/* Ensure child is reaped */
waitpid (priv->aipd_pid, NULL, WNOHANG);
priv->aipd_pid = -1;
}
aipd_timeout_remove (self);
priv->aipd_addr = 0;

View file

@ -737,7 +737,6 @@ nm_ppp_manager_start (NMPPPManager *manager,
NMSettingPPPOE *pppoe_setting;
NMCmdLine *ppp_cmd;
char *cmd_str;
GSource *ppp_watch;
g_return_val_if_fail (NM_IS_PPP_MANAGER (manager), FALSE);
g_return_val_if_fail (device != NULL, FALSE);
@ -775,12 +774,7 @@ nm_ppp_manager_start (NMPPPManager *manager,
nm_debug ("ppp started with pid %d", priv->pid);
ppp_watch = g_child_watch_source_new (priv->pid);
g_source_set_callback (ppp_watch, (GSourceFunc) ppp_watch_cb, manager, NULL);
g_source_attach (ppp_watch, NULL);
priv->ppp_watch_id = g_source_get_id (ppp_watch);
g_source_unref (ppp_watch);
priv->ppp_watch_id = g_child_watch_add (priv->pid, (GChildWatchFunc) ppp_watch_cb, manager);
priv->ppp_timeout_handler = g_timeout_add (NM_PPP_WAIT_PPPD, pppd_timed_out, manager);
priv->act_req = g_object_ref (req);
@ -842,6 +836,9 @@ ensure_killed (gpointer data)
if (kill (pid, 0) == 0)
kill (pid, SIGKILL);
/* ensure the child is reaped */
waitpid (pid, NULL, WNOHANG);
return FALSE;
}
@ -881,8 +878,11 @@ nm_ppp_manager_stop (NMPPPManager *manager)
if (priv->pid) {
if (kill (priv->pid, SIGTERM) == 0)
g_timeout_add (2000, ensure_killed, GINT_TO_POINTER (priv->pid));
else
else {
kill (priv->pid, SIGKILL);
/* ensure the child is reaped */
waitpid (priv->pid, NULL, WNOHANG);
}
priv->pid = 0;
}