http://qs321.pair.com?node_id=284621


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