in reply to Re: Testing whether a process has finished
in thread Testing whether a process has finished
Those docs are just a bit confusing and I can see why rovf is concerned that waitpid would suspend his program.
First, the docs say that non-blocking wait is only available for "machines supporting either the waitpid(2) or wait4(2) system calls". Perhaps rovf's machine is one of the machines that doesn't?
Second, it isn't entirely clear how one would write a program to use a non-blocking wait, assuming there is one. The docs give an example of a while loop but the ellipsis in the example are placed above the loop, not within the loop. I'm guessing that one is expected to use a polling pattern, but if that were to be non-blocking, one would have to place one's application code inside the polling loop rather than above it. To avoid suspending your program I'm guessing the code should look something like this?
use POSIX ":sys_wait_h"; #... do { # ... do some stuff while waiting ... # check in to see if the process has ended ... $kid = waitpid(-1, WNOHANG); } while $kid > 0;
Best, beth
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Testing whether a process has finished
by ikegami (Patriarch) on Sep 10, 2009 at 16:03 UTC | |
by rovf (Priest) on Sep 11, 2009 at 09:56 UTC | |
|
Re^3: Testing whether a process has finished
by rovf (Priest) on Sep 11, 2009 at 09:41 UTC | |
by ikegami (Patriarch) on Sep 11, 2009 at 14:14 UTC |