in reply to Doing every X seconds
(code updated)use POSIX ":sys_wait_h"; my $child = fork; if ($child) { # parent case my $res; while (not ($res = waitpid($child, WNOHANG))) { sleep 5; # check file list here # ... } if ($res == -1) { warn "fatal child error\n"; exit; } } else { # child case # insert job processing here exit; # child must explicitly exit otherwise both would continue e +xecuting this } # reach here if job processing completed successfully
One world, one people
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Doing every X seconds
by mr_mischief (Monsignor) on Aug 06, 2018 at 23:00 UTC | |
|