From 9967a29726b7fd37dfa910807f864be6e7868897 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Sun, 2 May 2010 08:07:50 -0400 Subject: Properly set up SIGCHLD handlers Instead of having all-purpose SIGCHLD handlers that try to catch every occurrence, we instead create a per-PID handler. This will allow us to specify callbacks to occur when certain children exit. --- src/providers/ldap/sdap_child_helpers.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/providers/ldap') diff --git a/src/providers/ldap/sdap_child_helpers.c b/src/providers/ldap/sdap_child_helpers.c index 273fc6787..c61f3cceb 100644 --- a/src/providers/ldap/sdap_child_helpers.c +++ b/src/providers/ldap/sdap_child_helpers.c @@ -77,7 +77,8 @@ static int sdap_child_destructor(void *ptr) return 0; } -static errno_t sdap_fork_child(struct sdap_child *child) +static errno_t sdap_fork_child(struct tevent_context *ev, + struct sdap_child *child) { int pipefd_to_child[2]; int pipefd_from_child[2]; @@ -118,6 +119,11 @@ static errno_t sdap_fork_child(struct sdap_child *child) fd_nonblocking(child->read_from_child_fd); fd_nonblocking(child->write_to_child_fd); + ret = child_handler_setup(ev, pid, NULL, NULL); + if (ret != EOK) { + return ret; + } + } else { /* error */ err = errno; DEBUG(1, ("fork failed [%d][%s].\n", err, strerror(err))); @@ -275,7 +281,7 @@ struct tevent_req *sdap_get_tgt_send(TALLOC_CTX *mem_ctx, goto fail; } - ret = sdap_fork_child(state->child); + ret = sdap_fork_child(state->ev, state->child); if (ret != EOK) { DEBUG(1, ("sdap_fork_child failed.\n")); goto fail; @@ -422,7 +428,6 @@ int setup_child(struct sdap_id_ctx *ctx) { int ret; const char *mech; - struct tevent_signal *sige; unsigned v; FILE *debug_filep; @@ -432,13 +437,6 @@ int setup_child(struct sdap_id_ctx *ctx) return EOK; } - sige = tevent_add_signal(ctx->be->ev, ctx, SIGCHLD, SA_SIGINFO, - child_sig_handler, NULL); - if (sige == NULL) { - DEBUG(1, ("tevent_add_signal failed.\n")); - return ENOMEM; - } - if (debug_to_file != 0 && ldap_child_debug_fd == -1) { ret = open_debug_file_ex("ldap_child", &debug_filep); if (ret != EOK) { -- cgit