"Craig A. Berry" <[EMAIL PROTECTED]> writes:
> Has anyone ever given any thought to implementing these? From perlipc.pod:
>
> =head2 Safe Pipe Opens
>
> Another interesting approach to IPC is making your single program go
> multiprocess and communicate between (or even amongst) yourselves. The
> open() function will accept a file argument of either C<"-|"> or C<"|-">
> to do a very interesting thing: it forks a child connected to the
> filehandle you've opened. The child is running the same program as the
> parent. This is useful for safely opening a file when running under an
> assumed UID or GID, for example. If you open a pipe I<to> minus, you can
> write to the filehandle you opened and your kid will find it in his
> STDIN. If you open a pipe I<from> minus, you can read from the filehandle
> you opened whatever your kid writes to his STDOUT.
>
> =cut
>
> Could we piggyback these on top of the current piping code? They
> don't presently work, as I discovered with new formatting tests in
> the latest t/op/write.t,
Well, the first major difficulty for us is "fork". Get that working
and the rest is a piece of cake.
The docs above doesn't make it very clear, but my own (admittedly naive)
understanding of fork is that it copies a snapshot of the parent's
VM to the child process, and starts the child just after the point where
the parent did called fork.
So both parent and child would continue running immediately after an
open(..,"-|"), with some (global flag?) variable being the only thing to
distinguishing parent from child.
AFAIK, we can't do that. VMS just doesn't do things that way.
Now, the docs above could also be interpreted to mean "start a subprocess
with Perl running this same script _from the beginning of the script_"
Something equivalent to: open(..."$^X $0 @ARGV|");
This we could emulate with a bit of fiddling around, but I don't think
it's really what is meant by the "-|".
> and before I say we have to skip the tests
> because we don't have the functionality I thought I'd run this by the
> list. Here's what we get now:
>
> perl -e "open(F,'|-');"
> %DCL-W-IVVERB, unrecognized command verb - check validity and spelling
> %DCL-W-IVVERB, unrecognized command verb - check validity and spelling
> \$\
> \$\
Not suprising...it's like putting a line:
$ -
in a DCL command procedure...it picks up the leading $ on the
following line and barfs.
--
Drexel University \V --Chuck Lane
======]---------->--------*------------<-------[===========
(215) 895-1545 _/ \ Particle Physics
FAX: (215) 895-5934 /\ /~~~~~~~~~~~ [EMAIL PROTECTED]