June Young writes:
> >You might want to try:
> >
>>    #! perl
>>    use vmsish 'status';
>>    system('sort jy.tmp foo.tmp');
>>    print "My status was: $?  extended status $^E\n";
> >
> >since it seems likely that your subprocess is dying before doing anything.
> >
> I tried your suggestion and get the following result:

> $perl test.prl  >temp2.tmp
> $type temp2.tmp
> My status was: 98954  extended status %RMS-E-FLK, file currently locked by another 
>user
> $xd foo.tmp
> %DIRECT-W-NOFILES, no files found

Okay, it looks like what's happening is that Perl has temp2.tmp open
for output, and the subprocess trys to open it as well (and finds that
it is locked, naturally enough).

Now, the sort normally wouldn't be sending anything to SYS$OUTPUT...or
if it did the more likely outcome would be a new version of temp2.tmp.
When I try it on my VMS 6.2 machine, I get an extra version of temp2.tmp.
Maybe that's a difference between 6.2 and 7.1

This, by the way, is one of the problems that the piping code tries to
handle...since system() doesn't use the piping code, then one gets a
slightly different behavior.

Here's the problem:  you have SYS$OUTPUT redirected to a file. VMS,
unlike Unix, doesn't do a very good job of shared write permissions
to variable-record-length files, so when you redirect to temp2.tmp,
that Perl program gets exclusive write access.

But when it spawns a subprocess, the default behavior is to
duplicate SYS$OUTPUT assignments...so how can the subprocess write
to its SYS$OUTPUT, when it points to a file locked by its parent?

In the piping code we get around that by having the subprocess's
SYS$OUTPUT point to a mailbox...then the parent Perl copies whatever
is written to that mailbox to the output file. It's kind of an ugly
kludge, but in fact is nearly identical to what LIB$SPAWN does.

As a workaround, you might want to try a program like:

    print `sort jy.tmp temp2.tmp`;  # note backquotes

or
    open(FOO,'|sort jy.tmp temp2.tmp');
    close(FOO);

these will go through the piping code, and perhaps avoid the file
locking problems. Make sure to reset your VMSPIPE.COM back to the
standard version before trying them, however.

And yes, it's clear that system() needs some more work on VMS.
--
 Drexel University       \V                    --Chuck Lane
======]---------->--------*------------<-------[===========
     (215) 895-1545     _/ \  Particle Physics
FAX: (215) 895-5934     /\ /~~~~~~~~~~~        [EMAIL PROTECTED]

Reply via email to