summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2007-07-30 19:29:47 -0400
committerDavid Zeuthen <davidz@redhat.com>2007-07-30 19:29:47 -0400
commit1f90f7e15095b9fdd0374fef98fbb3241a2b2ad6 (patch)
tree358d15a91b7667f688505bc1a7ae090b69ab5f6d
parent6e2d74cb86e529ab8ec964d6a0f632535fc78a9c (diff)
downloadpolkit-1f90f7e15095b9fdd0374fef98fbb3241a2b2ad6.tar.gz
use waitpid() to avoid Zombie processes
-rw-r--r--polkit-grant/polkit-grant.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/polkit-grant/polkit-grant.c b/polkit-grant/polkit-grant.c
index b4f6bf0..1217217 100644
--- a/polkit-grant/polkit-grant.c
+++ b/polkit-grant/polkit-grant.c
@@ -138,7 +138,9 @@ polkit_grant_unref (PolKitGrant *polkit_grant)
polkit_grant->func_remove_watch (polkit_grant, polkit_grant->child_watch_id);
}
if (polkit_grant->child_pid > 0) {
+ int status;
kill (polkit_grant->child_pid, SIGTERM);
+ waitpid (polkit_grant->child_pid, &status, 0);
}
if (polkit_grant->child_stdout_f != NULL) {
fclose (polkit_grant->child_stdout_f);
@@ -221,10 +223,15 @@ polkit_grant_set_functions (PolKitGrant *polkit_grant,
void
polkit_grant_child_func (PolKitGrant *polkit_grant, pid_t pid, int exit_code)
{
+ int status;
polkit_bool_t input_was_bogus;
+
g_return_if_fail (polkit_grant != NULL);
g_return_if_fail (polkit_grant->auth_in_progress);
+ g_debug ("pid %d terminated", pid);
+ waitpid (pid, &status, 0);
+
if (exit_code >= 2)
input_was_bogus = TRUE;
else
@@ -361,8 +368,11 @@ polkit_grant_cancel_auth (PolKitGrant *polkit_grant)
pid = polkit_grant->child_pid;
polkit_grant->child_pid = 0;
- if (pid > 0)
+ if (pid > 0) {
+ int status;
kill (pid, SIGTERM);
+ waitpid (pid, &status, 0);
+ }
polkit_grant->func_done (polkit_grant, FALSE, FALSE, polkit_grant->user_data);
}