At 6:47 PM -0800 1/8/05, Sampath Ravindhran wrote: >I have a perl script that calls waitpid, that doesn't seem to work at all on >VMS. A simple test case like the following: >---- >use POSIX ":sys_wait_h"; > >my $reap1 = waitpid("53CCDA08",&WNOHANG); >print "Exit = $?\n"; >print "REAP = $reap1\n"; >------- > >simply prints out >--- >Exit = 256 >REAP = 53 >--- >regardless of whether the process with PID 53CCDA08 (in example above) exists >or not. Is it required that the targeted waitpid process be a subprocess of >the current process calling waitpid() ? > >On Unix platforms, they are able to 'reap' a process that has already exited >and get its final exit status? Is this feasible on VMS?
Your first problem is that the pid needs to be expressed in decimal, not hex. The reason it tells you it reaped pid 53 is that when interpreting 53CCDA08 as a decimal value it strips off anything after the 53. Also, do you really mean "&WNOHANG" rather than "WNOHANG"? In Perl, the ampersand means what follows is a subroutine name. Now, to get on to your questions. If a process was created by the Perl interpreter you are currently running (i.e., one of your own children) or it was created by the CRTL in your parent process, then you should in recent versions of Perl be able to get its termination status. For other processes, I'm not sure there is a guaranteed way to get the final status, though reading the accounting record might be the best supported way. This would be tricky from Perl though perhaps not impossible. Reading the termination mailbox as Jordan suggests elsewhere in this thread really only works if you are the one who created the mailbox and passed it to SYS$CREPRC. Otherwise you are stealing a message from the mailbox that another process will also be trying to read. One or the other of you will likely hang because the message you are expecting isn't there anymore. I'm speaking from experience as I put this into Perl's waitpid implementation but had to take it out again once I realized the process whose termination message I'd stolen might hang. Oh, and not all processes even have termination mailboxes; it's an optional argument to SYS$CREPRC. -- ________________________________________ Craig A. Berry mailto:[EMAIL PROTECTED] "... getting out of a sonnet is much more difficult than getting in." Brad Leithauser