diff options
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/crond.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/miscutils/crond.c b/miscutils/crond.c index 96131cae4..6a384fdfb 100644 --- a/miscutils/crond.c +++ b/miscutils/crond.c | |||
| @@ -989,7 +989,7 @@ static int check_completions(void) | |||
| 989 | if (line->cl_pid <= 0) | 989 | if (line->cl_pid <= 0) |
| 990 | continue; | 990 | continue; |
| 991 | 991 | ||
| 992 | r = waitpid(line->cl_pid, NULL, WNOHANG); | 992 | r = safe_waitpid(line->cl_pid, NULL, WNOHANG); |
| 993 | if (r < 0 || r == line->cl_pid) { | 993 | if (r < 0 || r == line->cl_pid) { |
| 994 | process_finished_job(file->cf_username, line); | 994 | process_finished_job(file->cf_username, line); |
| 995 | if (line->cl_pid == 0) { | 995 | if (line->cl_pid == 0) { |
| @@ -1001,6 +1001,14 @@ static int check_completions(void) | |||
| 1001 | /* else: r == 0: "process is still running" */ | 1001 | /* else: r == 0: "process is still running" */ |
| 1002 | file->cf_has_running = 1; | 1002 | file->cf_has_running = 1; |
| 1003 | } | 1003 | } |
| 1004 | |||
| 1005 | /* Reap any other children we don't actively track. | ||
| 1006 | * Reportedly, some people run crond as init process! | ||
| 1007 | * Thus, we need to reap orphans, like init does. | ||
| 1008 | */ | ||
| 1009 | while (wait_any_nohang(NULL) > 0) | ||
| 1010 | continue; | ||
| 1011 | |||
| 1004 | //FIXME: if !file->cf_has_running && file->deleted: delete it! | 1012 | //FIXME: if !file->cf_has_running && file->deleted: delete it! |
| 1005 | //otherwise deleted entries will stay forever, right? | 1013 | //otherwise deleted entries will stay forever, right? |
| 1006 | num_still_running += file->cf_has_running; | 1014 | num_still_running += file->cf_has_running; |
