* [Bug 2855] Parser fix for conditional leap smear code. Harlan Stenn.
* [Bug 2855] Report leap smear in the REFID. Harlan Stenn.
+* [Bug 2856] ntpd should wait() on terminated child processes. Paul Green.
* refidsmear test cleanup. Tomasz Flendrich.
* refidsmear function support and tests. Harlan Stenn.
* sntp/tests/Makefile.am: remove g_nameresolution.cpp as it tested
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
+#include <sys/wait.h>
#include "iosignal.h"
#include "ntp_stdlib.h"
}
+/*
+ * harvest_child_status() runs in the parent.
+ */
+static void
+harvest_child_status(
+ blocking_child * c
+ )
+{
+ if (c->pid)
+ {
+ /* Wait on the child so it can finish terminating */
+ if (waitpid(c->pid, NULL, 0) == c->pid)
+ TRACE(4, ("harvested child %d\n", c->pid));
+ else msyslog(LOG_ERR, "error waiting on child %d: %m", c->pid);
+ }
+}
+
/*
* req_child_exit() runs in the parent.
*/
c->req_write_pipe = -1;
return 0;
}
+ /* Closing the pipe forces the child to exit */
+ harvest_child_status(c);
return -1;
}
blocking_child * c
)
{
- if (-1 != c->req_write_pipe) {
- close(c->req_write_pipe);
- c->req_write_pipe = -1;
- }
+ harvest_child_status(c);
if (-1 != c->resp_read_pipe) {
(*addremove_io_fd)(c->resp_read_pipe, c->ispipe, TRUE);
close(c->resp_read_pipe);
"send_blocking_req_internal: short write %d of %d",
rc, octets);
+ /* Fatal error. Clean up the child process. */
+ req_child_exit(c);
exit(1); /* otherwise would be return -1 */
}