From b525aa57f138f67624038c4a1bdeca9042bcf2f0 Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Tue, 27 Aug 2013 11:11:05 +0200 Subject: SIGCHLD handler: do not call callback when pvt data where freed https://fedorahosted.org/sssd/ticket/1992 --- src/providers/child_common.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/providers/child_common.c') diff --git a/src/providers/child_common.c b/src/providers/child_common.c index 1cead3893..d1e84a97d 100644 --- a/src/providers/child_common.c +++ b/src/providers/child_common.c @@ -252,7 +252,8 @@ struct sss_child_ctx_old { }; int child_handler_setup(struct tevent_context *ev, int pid, - sss_child_callback_t cb, void *pvt) + sss_child_callback_t cb, void *pvt, + struct sss_child_ctx_old **_child_ctx) { struct sss_child_ctx_old *child_ctx; @@ -276,9 +277,30 @@ int child_handler_setup(struct tevent_context *ev, int pid, child_ctx->pvt = pvt; DEBUG(8, ("Signal handler set up for pid [%d]\n", pid)); + + if (_child_ctx != NULL) { + *_child_ctx = child_ctx; + } + return EOK; } +void child_handler_destroy(struct sss_child_ctx_old *ctx) +{ + errno_t ret; + + /* We still want to wait for the child to finish, but the caller is not + * interested in the result anymore (e.g. timeout was reached). */ + ctx->cb = NULL; + ctx->pvt = NULL; + + ret = kill(ctx->pid, SIGKILL); + if (ret == -1) { + ret = errno; + DEBUG(SSSDBG_MINOR_FAILURE, ("kill failed [%d][%s].\n", ret, strerror(ret))); + } +} + /* Async communication with the child process via a pipe */ struct write_pipe_state { -- cgit