Apart from that there is no "sleep" command under native Win32, which means that system 'sleep 3'; isn't going to do anything useful, in what way does it "not work"?
Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.
| [reply] [d/l] |
The primary problem is that the CHLD signal handler isn't being properly installed for reasons which I don't understand. In other words, the reaper subroutine is never called when a child process (spawned by Perl's core fork() function) dies.
| [reply] |
This section from perlman:perlwin32 (from the AS 5.8 (805) distribution) gives a hint to the problem:
Signal handling may not behave as on Unix platforms (where it doesn't exactly ``behave'', either :). For instance, calling die() or exit() from signal handlers will cause an exception, since most implementations of signal() on Win32 are severely crippled. Thus, signals may work only for simple things like setting a flag variable in the handler. Using signals under this port should currently be considered unsupported.
That said, you appear to be trying to use the signal handler to reap zombied processes, which is not required under AS builds of perl as fork'd processes aren't actually processes, they are implemented as (Win32 native!) threads rather than Unix style COW processes.
The upshot of that is that you don't need to reap forked processes under AS, when the 'process' exit's (or simply falls off the end of the script) the thread goes away and no further action need be taken.
If your script is only to run under Win32, then this actually simplifies the code. If you need to make it portable, then you need to test for platform and install the signal handler conditionally.
You should also read perlman:perlfork from the AS distribution for further details on the differences between their implementation and the standard unix version.
Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.
| [reply] |
This is a list I gathered, and it tells you, for windows and solaris, what signals you can catch. CHLD is not there for windows.
- Windows: ABRT, FPE, ILL, INT, SEGV, TERM
- Solaris: ABRT, ALRM, BUS, CHLD, CONT, EMT, FPE, HUP, ILL, INT, IO, KILL, PIPE, POLL, PROF, PWR, QUIT, SEGV, STOP, SYS, TERM, TRAP, TSTP TTIN, TTOU, URG, USR1, USR2, VTALRM, WINCH, XCPU, XFSZ
| [reply] |