summaryrefslogtreecommitdiffstats
path: root/src/util/child_common.c
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2013-08-30 10:56:04 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-09-12 13:47:00 +0200
commitf06e541c16ea5da9391bf0500b2f2b84d4b872b1 (patch)
tree0dc1b6750f0020a18bff1ead7c5f234b3771c258 /src/util/child_common.c
parentb77cf09d36615127b682bc886d3c3ca92f5ce698 (diff)
downloadsssd-f06e541c16ea5da9391bf0500b2f2b84d4b872b1.tar.gz
sssd-f06e541c16ea5da9391bf0500b2f2b84d4b872b1.tar.xz
sssd-f06e541c16ea5da9391bf0500b2f2b84d4b872b1.zip
SIGCHLD handler: do not call callback when pvt data was freed
https://fedorahosted.org/sssd/ticket/1992
Diffstat (limited to 'src/util/child_common.c')
-rw-r--r--src/util/child_common.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/util/child_common.c b/src/util/child_common.c
index 5f0b26595..fe4684fb0 100644
--- a/src/util/child_common.c
+++ b/src/util/child_common.c
@@ -260,7 +260,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;
@@ -284,9 +285,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 {