Re: fork issue in OVMS perl script

"Craig A. Berry" <[email protected]>
Newsgroups gmane.comp.lang.perl.ports.vms
Message-ID <[email protected]>
On Oct 12, 2009, at 5:23 AM, purnima bhandari wrote:

> Hi,
> I am new to OpenVMS Perl. I know that fork is currently not supported
> in the OVMS Perl (perl 5.8.6 on Ia64, VMS 8.3). I am currently trying
> to port the Perl script which has fork call and running successfully
> in UNIX environment. I saw in the readme documentation that we can use
> the vfork/exec instead. But I don't know how to use those in the Perl
> script and it is failing with below error.
>
> Below is the script snippet.
>
>
> Code snippet:
>
>
>  outln("($$) run_service()");
>  $log->debugln("($$) enter run_service()");
>
> # $pid = fork();  // Original script replaced with vfork below
>
>  $pid = vfork();
>  if($pid == 0) {         # we are the child
>    $SIG{CHLD} = $old_sigchld_hnd;
>    $SIG{INT}  = $old_sigint_hnd;
>
>
>
>
> The error:
>
> (574622047) enter run_service()run_observice calling vfork
> Undefined subroutine &main::vfork called at /opt/ovt/bin/ovt.pl line  
> 356.
> %SYSTEM-F-ABORT, abort
>
>
> Please guide me, where I am going wrong?
>

Not sure what the README in 5.8.6 says (that's a five-year-old release  
of Perl), but currently in perlvms.pod we say:

=item fork

While in principle the C<fork> operator could be implemented via
(and with the same rather severe limitations as) the CRTL C<vfork()>
routine, and while some internal support to do just that is in
place, the implementation has never been completed, making C<fork>
currently unavailable.  A true kernel C<fork()> is expected in a
future version of VMS, and the pseudo-fork based on interpreter
threads may be available in a future version of Perl on VMS (see
L<perlfork>).  In the meantime, use C<system>, backticks, or piped
filehandles to create subprocesses.

---

where the language indicates a bit better that the reference to vfork  
is not a reference to a Perl function but rather to the CRTL basis  
upon which a fork() in Perl could be (but isn't) implemented.  The  
last sentence is the important one: use system, backticks, or piped  
filehandles.  I'll just add that you may also want to look on CPAN for  
modules in the IPC::* namespace where there are some convenient  
abstractions that have had some effort to work portably.

________________________________________
Craig A. Berry
mailto:[email protected]

"... getting out of a sonnet is much more
  difficult than getting in."
                  Brad Leithauser
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.