Section 11.6. Creating Unnamed Pipes

   


11.6. Creating Unnamed Pipes

Unnamed pipes are similar to named pipes, but they do not exist in the file system. They have no pathnames associated with them, and they and all their remnants disappear after the final file descriptor that references them is closed. They are almost exclusively used for interprocess communication between a child and parent processes or between sibling processes.

Shells use unnamed pipes to execute commands such as ls | head. The ls process writes to the same pipe that head reads its input from, yielding the results the user intended.

Creating an unnamed pipe results in two file descriptors, one of which is read-only and the other one of which is write-only.

 #include <unistd.h> int pipe(int fds[2]); 


The sole parameter is filled in with the two returned file descriptors, fds[0] for reading and fds[1] for writing.


       
    top
     


    Linux Application Development
    Linux Application Development (paperback) (2nd Edition)
    ISBN: 0321563220
    EAN: 2147483647
    Year: 2003
    Pages: 168

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net