Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Re: Re: When starting a process, at what point does "open()" return?

by MarkM (Curate)
on Aug 18, 2003 at 16:11 UTC ( #284621=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: When starting a process, at what point does "open()" return?
in thread When starting a process, at what point does "open()" return?

I did some extra checking for you. I hate unexplained behaviour as well... :-)

With open("program |") Perl opens two pipes on systems that provide fork() (UNIX). The first pipe is for capturing STDOUT, and remains open after execve(). The second pipe is for passing an errno value from the new child to the parent, and is automatically closed as part of execve(). If execve() fails, the value of errno is written in native binary format over the second pipe. The caller monitors this second pipe, and waits until the second pipe closes before it succeeds.

I wasn't able to quickly determine when this code was introduced into Perl. It does make things convenient. :-)

Cheers,
mark


Comment on Re: Re: Re: When starting a process, at what point does "open()" return?
perl56delta - what's new for perl v5.6.0
by Anonymous Monk on Aug 18, 2003 at 19:50 UTC
    system(), backticks and pipe open now reflect exec failure
    On Unix and similar platforms, system(), qx() and open(FOO, ``cmd |'') etc., are implemented via fork() and exec(). When the underlying exec() fails, earlier versions did not report the error properly, since the exec() happened to be in a different process. The child process now communicates with the parent about the error in launching the external command, which allows these constructs to return with their usual error value and set $!.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2014-04-21 06:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (492 votes), past polls