aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2025-07-30 20:02:23 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2025-07-30 20:02:23 +0200
commita98b95b715359a8b002d1cb8e1f998a4afa2c73e (patch)
treef77e0efb753c16297df47d825ad1d0bf829320ec /miscutils
parent41f677ec5daccaeae616a0bbf508d2a2d54bdac7 (diff)
downloadbusybox-w32-a98b95b715359a8b002d1cb8e1f998a4afa2c73e.tar.gz
busybox-w32-a98b95b715359a8b002d1cb8e1f998a4afa2c73e.tar.bz2
busybox-w32-a98b95b715359a8b002d1cb8e1f998a4afa2c73e.zip
*: use safe_waitpid() or wait_any_nohang() where approppriate
function old new delta crond_main 1227 1237 +10 init_main 804 794 -10 wait_one 263 252 -11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 10/-21) Total: -11 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/crond.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/miscutils/crond.c b/miscutils/crond.c
index b29745576..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) {
@@ -1002,8 +1002,12 @@ static int check_completions(void)
1002 file->cf_has_running = 1; 1002 file->cf_has_running = 1;
1003 } 1003 }
1004 1004
1005 /* Reap any other children we don't actively track */ 1005 /* Reap any other children we don't actively track.
1006 while (waitpid(-1, NULL, WNOHANG) > 0); 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;
1007 1011
1008//FIXME: if !file->cf_has_running && file->deleted: delete it! 1012//FIXME: if !file->cf_has_running && file->deleted: delete it!
1009//otherwise deleted entries will stay forever, right? 1013//otherwise deleted entries will stay forever, right?