diff --git a/src/slurmd/slurmstepd/mgr.c b/src/slurmd/slurmstepd/mgr.c index dc8fdb19a73af6d4e2b07f4c9e8866e45dc2769b..359818221b47d4cab5616d46fed51b516f7c9ce3 100644 --- a/src/slurmd/slurmstepd/mgr.c +++ b/src/slurmd/slurmstepd/mgr.c @@ -1148,8 +1148,10 @@ static void exec_wait_info_destroy (struct exec_wait_info *e) if (e == NULL) return; - close (e->parentfd); - close (e->childfd); + if (e->parentfd >= 0) + close (e->parentfd); + if (e->childfd >= 0) + close (e->childfd); e->id = -1; e->pid = -1; } @@ -1172,9 +1174,17 @@ static struct exec_wait_info * fork_child_with_wait_info (int id) exec_wait_info_destroy (e); return (NULL); } - else if (e->pid == 0) /* In child, close parent fd */ + /* + * Close parentfd in child, and childfd in parent: + */ + if (e->pid == 0) { close (e->parentfd); - + e->parentfd = -1; + } + else { + close (e->childfd); + e->childfd = -1; + } return (e); }