summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2013-06-24 14:53:27 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-07-17 15:01:51 +0200
commit711bba7e2f72a816774effa389ad13bcc46e7843 (patch)
treea101e81f75892c794b3613be0fff0c4bd481f5a2 /src/util
parenta7401bf72db3a6eb62b1628f9dd141f7118e3510 (diff)
downloadsssd-711bba7e2f72a816774effa389ad13bcc46e7843.tar.gz
sssd-711bba7e2f72a816774effa389ad13bcc46e7843.tar.bz2
sssd-711bba7e2f72a816774effa389ad13bcc46e7843.zip
SIGCHLD handler: do not call callback when pvt data where freed
https://fedorahosted.org/sssd/ticket/1992
Diffstat (limited to 'src/util')
-rw-r--r--src/util/child_common.c24
-rw-r--r--src/util/child_common.h8
2 files changed, 30 insertions, 2 deletions
diff --git a/src/util/child_common.c b/src/util/child_common.c
index a42d3a42..ec2baf01 100644
--- a/src/util/child_common.c
+++ b/src/util/child_common.c
@@ -262,7 +262,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;
@@ -286,9 +287,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 {
diff --git a/src/util/child_common.h b/src/util/child_common.h
index 237969f2..95865bb5 100644
--- a/src/util/child_common.h
+++ b/src/util/child_common.h
@@ -78,9 +78,15 @@ typedef void (*sss_child_callback_t)(int child_status,
struct tevent_signal *sige,
void *pvt);
+struct sss_child_ctx_old;
+
/* Set up child termination signal handler */
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);
+
+/* Destroy child termination signal handler */
+void child_handler_destroy(struct sss_child_ctx_old *ctx);
/* Async communication with the child process via a pipe */
struct tevent_req *write_pipe_send(TALLOC_CTX *mem_ctx,