lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


--- Gé Weijers <ge@weijers.org> wrote:
> Daniel Bernstein's observation was that if the
> socket interfaces would have returned 2 file 
> descriptors instead of one 'close' could  
> have done the job
However, given the generic and widespread usage of
fork()/exec(), even 2 file descriptors may not be
enough. As they are in general passed to childs which
unless explicitly closed in the forked child, would
have the same effect as it is now. So a shutdown() is
still needed which effectively means, close this
pipe/socket regardless of how many fd are dup().

I was in this situation trying to create a loopback
pipe in lua like pipethrough("gzip -dc"). Initially, I
juse use pipe(2) create the pipe pair then dup
stdin/stdout and fork()/exec(). However, even I close
the write end of the parent, I still don't get the
result because it was passed to the fork() child. I
have to explicitly close them before the exec().

With socketpair(), a shutdown("write") from the parent
would do the job.



 
____________________________________________________________________________________
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
http://answers.yahoo.com/dir/?link=list&sid=396546091