hello,
I am having some trouble with a piece of code that was originally written
for UNIX and has working there without any problems. The code checks for
the finished or stopped child processes, and reaps them if they have
terminated. Recently, people have started to use my program on windows and
have complained that this fragment does not work:
$pid = waitpid(-1, &WNOHANG);
if ($pid == -1 || $pid == 0) { last; }
log_msg("Waited for child $pid");
if (WIFEXITED($?)) {
$exitcode = $? >> 8;
if ($exitcode) {
log_msg("Child $pid terminated with non-zero exitcode $exitcode");
} else { execute_action(); }
}
The users have received a warning about the missing WIFEXITED macro, which
is a part of POSIX standard. This macro is required for UNIX, since
waitpid() also reports processes that have just stopped and not
terminated. WIFEXITED is used on UNIX to check whether the
child process has really finished.
What about waitpid() on windows - is it possible that still running
processes are reported? If this situation never occurs on windows, I guess
it would be safe to drop WIFEXITED from the windows version of my code?
Other question - when browsing the archives of this list I noticed a
message that suggested not to use waitpid(-1, &WNOHANG), because it is not
working (because of the -1 parameter). Is this true? I have made some
tests, and things seem to be working fine with -1 on Win2000 and NT, but
not on Win98. On Win98, waitpid() always returned 0 as the exitcode of the
child process, even when the child returned 1 or other non-zero value.
The perl manual just says that waitpid() should return the process id of
the stopped or finished child, or -1 if there are no such children. 0
could also be returned on some platforms, to signal that there exist
children but they are all in running state. Is windows one of
these platforms? (answer to that could also answer one of my previous
questions)
Can someone clarify these issues? The perl manual tells very little
about things that are more or less windows specific :(
Thanks in advance!
regards
risto
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users