ctdb-common: Avoid race between fd and signal events
[vlendec/samba-autobuild/.git] / ctdb / common / run_proc.c
index 97895b383b9485aa5358df88c14dfaed51f9827c..037b6d9651de358035a6dbc04494e99549420f7e 100644 (file)
@@ -295,6 +295,13 @@ again:
                proc->result.sig = WTERMSIG(status);
        }
 
+       /* Confirm that all data has been read from the pipe */
+       if (proc->fd != -1) {
+               proc_read_handler(ev, proc->fde, 0, proc);
+               TALLOC_FREE(proc->fde);
+               proc->fd = -1;
+       }
+
        /* Active run_proc request */
        if (proc->req != NULL) {
                run_proc_done(proc->req);