+static void exit_at_end()
+{
+ exit(0);
+}
+
+static void wait_child(int signum, void* arg)
+{
+ pid_t pid = (pid_t)(intptr_t)arg;
+ pid_t pidchld = childpid;
+
+ if (pidchld == pid) {
+ childpid = 0;
+ if (!SELF_PGROUP)
+ killpg(pidchld, SIGKILL);
+ waitpid(pidchld, NULL, 0);
+ jobs_exit(exit_at_end);
+ } else {
+ waitpid(pid, NULL, 0);
+ }
+}
+