in reply to fork() doesn't care about my sleep()?

The child exits, with sends a signal to the parent. This causes the sleep() to be interrupted. You may want to use a sleep that does sub second timings, and inspect the return value of sleep, sleeping again if necessary.
  • Comment on Re: fork() doesn't care about my sleep()?

Replies are listed 'Best First'.
Re^2: fork() doesn't care about my sleep()?
by happy.barney (Friar) on Nov 11, 2010 at 08:34 UTC
    my $sleep = 1; $SIG{ALRM} = sub { $sleep = 0; }; $SIG{CHLD} = sub { ... child ends here ... }; ... if (... $pid == 0) { ... child here } else { $sleep = 1; alarm (1); wait_for_signal while $sleep; # search for POSIX, SigAction, ... }