----- Original Message -----
From: "Grant Hopwood" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 02, 2001 5:47 PM
Subject: waitpid(-1, &WNOHANG) blocking on Win32.


> Can anyone confirm for me that it is (or isn't) possible to do a
> nonblocking waitpid() on Activestate 5.6?
Grant,

If you pass waitpid the PID of the the child, it will not block. See example
below:
# process wait blocking test.
my $kid;
my $child = fork();

STDOUT->FileHandle::autoflush(1);
STDERR->FileHandle::autoflush(1);

if ($child == 0) {
 print "I am the child and my process id is $$\nChild Sleeping\n";
 sleep(30);
 print "I am the child and I'm done!\n";
 exit();
} else {
 print "I am the parent and my process id is $$\n";
 do {
  print "Parent sleeping\n";
  sleep(1);
  print "Checking on Child $child.\n";
  $kid = waitpid($child, &WNOHANG);
  print "kid: $kid\n";
 } while (($kid == $child) || ($kid == 0));
}


Edward G. Orton, GWN Consultants Inc.
Office: 613-860-3186, Home: 613-764-3186, Fax: 613-764-1721
email: [EMAIL PROTECTED]

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin

Reply via email to