Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: No inherited file handles with tie() and exec()

by ikegami (Patriarch)
on Apr 15, 2009 at 02:19 UTC ( [id://757527]=note: print w/replies, xml ) Need Help??


in reply to No inherited file handles with tie() and exec()

A tied handle is a Perl variable that Perl presents as a file handle, but isn't. When a program passes a tied handle to a Perl IO function, Perl calls a subroutine instead of doing IO calls. There's no way for Perl to cause a child process (that might not even be a Perl program) to call a sub in its parent instead of writing to a handle. As such, children cannot inherit tied handles or any other handle without a fileno.
  • Comment on Re: No inherited file handles with tie() and exec()

Replies are listed 'Best First'.
Re^2: No inherited file handles with tie() and exec()
by saintmike (Vicar) on Apr 15, 2009 at 02:27 UTC
    Yeah, that makes sense. And I guess the reason why case #2 works with tie() and a forked process is that in this case the child knows about the tie()ed subroutine as well. Thanks!

      I had a problem confirming your statement until I realize it's very unclear what you mean by a process "knowing a sub".

      The child gets a copy of the tied var, the sub and everything else in the process's memory space. It only works because 1) the child uses the copy of the tied var and 2) the child process doesn't expect to cause any changes in the parent.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://757527]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 05:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found