-/****************************************************************************
-wait for a process to exit, calling io_flush while waiting
-****************************************************************************/
-static void wait_process(pid_t pid, int *code_ptr)
+/* Works like waitpid(), but if we already harvested the child pid in our
+ * sigchld_handler(), we succeed instead of returning an error. */
+pid_t wait_process(pid_t pid, int *status_ptr, int flags)