summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2017-09-29 12:45:24 +0200
committerStefan Metzmacher <metze@samba.org>2017-10-02 09:05:22 +0200
commit634514a8d431b45a070f1d052b552bcf5f0a3bee (patch)
tree8d1d22bde1432428640223cbb7df14401b338e56 /lib
parent3711ec4dafc098668eb0c1bee9dee62838024a59 (diff)
downloadsamba-634514a8d431b45a070f1d052b552bcf5f0a3bee.tar.gz
lib/util/run_cmd: prevent zombies in samba_runcmd_send on timeout
Ensure the state desctructor calls tfork_destroy to reap the waiter and worker processes. Otherwise we leave the waiter process as a zombie behind us as we never call waitpid on it in case of a timeout or talloc_free() from the caller. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13062 Pair-programmed-with: Stefan Metzmacher <metze@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> (cherry picked from commit 9a8eeabd95afca2e88666b3e8f2af954dbf23ba9)
Diffstat (limited to 'lib')
-rw-r--r--lib/util/util_runcmd.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/util/util_runcmd.c b/lib/util/util_runcmd.c
index 6077fddde56..ef3402ad33f 100644
--- a/lib/util/util_runcmd.c
+++ b/lib/util/util_runcmd.c
@@ -34,11 +34,10 @@
static int samba_runcmd_state_destructor(struct samba_runcmd_state *state)
{
- if (state->pid > 0) {
- kill(state->pid, SIGKILL);
- waitpid(state->pid, NULL, 0);
- state->pid = -1;
+ if (state->tfork != NULL) {
+ tfork_destroy(&state->tfork);
}
+ state->pid = -1;
if (state->fd_stdin != -1) {
close(state->fd_stdin);
@@ -275,6 +274,7 @@ static void samba_runcmd_io_handler(struct tevent_context *ev,
tevent_req_error(req, errno);
return;
}
+ state->pid = -1;
TALLOC_FREE(fde);
if (WIFEXITED(status)) {