diff options
Diffstat (limited to 'scan.c')
-rw-r--r-- | scan.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -393,6 +393,7 @@ main(int argc, char **argv) int kq, dir_fd, lock_fd; struct kevent evt[6]; struct procctl_reaper_kill rk; + struct procctl_reaper_status rs; pid_t mypid = getpid(); if (argc > 1) @@ -462,9 +463,16 @@ main(int argc, char **argv) } end: - rk.rk_sig = SIGTERM; - rk.rk_flags = REAPER_KILL_CHILDREN; - procctl(P_PID, mypid, PROC_REAP_KILL, &rk); + if (procctl(P_PID, mypid, PROC_REAP_STATUS, &rs) != -1) { + if (rs.rs_children > 0) { + rk.rk_sig = SIGTERM; + rk.rk_flags = REAPER_KILL_CHILDREN; + if (procctl(P_PID, mypid, PROC_REAP_KILL, &rk)) + perror("procctl()"); + } + } else { + perror("procctl()"); + } if (close(kq) == -1) perror("close()"); @@ -475,6 +483,7 @@ end: reset_signals(); + fprintf(stderr, "Waiting for children to exit\n"); reap_all(); /* XXX: Maybe remove this for shorter shutdown? */ return 0; |