The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 04-24-2008
shamrock shamrock is offline
Registered User
 

Join Date: Oct 2007
Location: USA
Posts: 500
If you read Perderabo's post carefully you would not be asking this question. The scenario you are describing cannot happen since dup2 will do what you tell it to instead of picking the lowest file descriptor available and assigning it to pfds. The notion of parent and child process is relative as this is decided only by the return value of the fork() function as to which process becomes the parent and which the child. In your case the "ls" process is the child process (though a small code change can swap this around) while the "wc -l" is the parent process.
Reply With Quote