[SSSD] [PATCH] Remove signal event if child was terminated by a signal
Sumit Bose
sbose at redhat.com
Fri May 21 09:31:34 UTC 2010
Hi,
currently we remove the signal event and call the callbacks only if the
child finished normally, i.e. not killed by a signal. This patch changes
this and updates ipa_dyndns_child_handler(), currently the only
callback, accordingly.
bye,
Sumit
-------------- next part --------------
From ce8dee004c25f4fe74da7da7d7c2817fc130ff4e Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose at redhat.com>
Date: Fri, 21 May 2010 11:09:11 +0200
Subject: [PATCH] Remove signal event if child was terminated by a signal
---
src/providers/child_common.c | 26 +++++++++++++++++++++-----
src/providers/ipa/ipa_dyndns.c | 9 ++++++++-
2 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/src/providers/child_common.c b/src/providers/child_common.c
index a8a4e04..a242338 100644
--- a/src/providers/child_common.c
+++ b/src/providers/child_common.c
@@ -319,12 +319,28 @@ void child_sig_handler(struct tevent_context *ev,
DEBUG(1, ("waitpid failed [%d][%s].\n", err, strerror(err)));
} else if (ret == 0) {
DEBUG(1, ("waitpid did not found a child with changed status.\n"));
- } else if WIFEXITED(child_ctx->child_status) {
- if (WEXITSTATUS(child_ctx->child_status) != 0) {
- DEBUG(1, ("child [%d] failed with status [%d].\n", ret,
- child_ctx->child_status));
+ } else {
+ if WIFEXITED(child_ctx->child_status) {
+ if (WEXITSTATUS(child_ctx->child_status) != 0) {
+ DEBUG(1, ("child [%d] failed with status [%d].\n", ret,
+ WEXITSTATUS(child_ctx->child_status)));
+ } else {
+ DEBUG(4, ("child [%d] finished successfully.\n", ret));
+ }
+ } else if WIFSIGNALED(child_ctx->child_status) {
+ DEBUG(1, ("child [%d] was terminated by signal [%d].\n", ret,
+ WTERMSIG(child_ctx->child_status)));
} else {
- DEBUG(4, ("child [%d] finished successfully.\n", ret));
+ if WIFSTOPPED(child_ctx->child_status) {
+ DEBUG(7, ("child [%d] was stopped by signal [%d].\n", ret,
+ WSTOPSIG(child_ctx->child_status)));
+ }
+ if WIFCONTINUED(child_ctx->child_status) {
+ DEBUG(7, ("child [%d] was resumed by delivery of SIGCONT.\n",
+ ret));
+ }
+
+ return;
}
/* Invoke the callback in a tevent_immediate handler
diff --git a/src/providers/ipa/ipa_dyndns.c b/src/providers/ipa/ipa_dyndns.c
index b1edc19..a86c696 100644
--- a/src/providers/ipa/ipa_dyndns.c
+++ b/src/providers/ipa/ipa_dyndns.c
@@ -514,13 +514,20 @@ static void ipa_dyndns_child_handler(int child_status,
{
struct tevent_req *req = talloc_get_type(pvt, struct tevent_req);
- if (WEXITSTATUS(child_status) != 0) {
+ if (WIFEXITED(child_status) && WEXITSTATUS(child_status) != 0) {
DEBUG(1, ("Dynamic DNS child failed with status [%d]\n",
child_status));
tevent_req_error(req, EIO);
return;
}
+ if WIFSIGNALED(child_status) {
+ DEBUG(1, ("Dynamic DNS child was terminated by signal [%d]\n",
+ WTERMSIG(child_status)));
+ tevent_req_error(req, EIO);
+ return;
+ }
+
tevent_req_done(req);
}
--
1.6.6.1
More information about the sssd-devel
mailing list