[KLUG Programming] perl fork question

Peter Buxton programming@kalamazoolinux.org
Fri, 19 Sep 2003 13:40:22 -0400


On Fri, Sep 19, 2003 at 10:56:59AM -0400, Adam Williams was only escaped
   alone to tell thee:

> >  What I am interested in specifically is a filehandle.  I would be
> >  willing to print a variable to a file in the child and read it in
> >  the parent but I am not sure how to accomplish this with a scalar
> >  filehandle.
> 
> I don't think you can pass filehandles as values.  The fork'd child
> does inherit all the filehandles however.

How much data are you trying to pass? If you're doing something
important and long-lived, with small data, you could create a Unix
domain socket and pass UDP messages over it.

If your needs are rather lightweight, it is also possible to fork off a
program and then tie arbitrary filehandles to each other in C, and I
imagine Perl is much the same:

http://iis1.cps.unizar.es/Oreilly/perl/cookbook/ch16_11.htm

Or use SysV IPC, using IPC::Msg:

http://iis1.cps.unizar.es/Oreilly/perl/cookbook/ch16_13.htm

-- 
0
I am not a Pillar, but a Buttress, of the Established
Church. I support it from without. -- Lord Melbourne