| 
                  Pipes
                   and FIFOs  | 
            
| 
                   
                      
                     Prof. David Bernstein
                       | 
            
| Computer Science Department | 
| bernstdh@jmu.edu | 
               
            
         
            
         
         
            
         
         
            
         
         
            
         PIP_BUF bytes) are guaranteed
              to be atomic (hence, if multiple processes are writing to
              the same pipe/FIFO their bytes won't be "intermingled")
         
            
         SIGPIPE signal
         
            
         
         
            
         int mkfifo(const char *name, mode_t mode)
               
                        name
                      | 
                     the pathname of the FIFO | 
                        mode
                      | 
                     the permissions (as on files) | 
| Return | 0 on success; -1 on error | 
Since you need to have at least one writing process on one end and
one writing process on the other, by default a call to open() one
end (e.g., O_WRONLY will block until another process
calls open() for the other end (e.g., O_RDONLY).
This behavior can be modified with the O_NONBLOCK flag
(though there are many details to consider).
         
            
         ls -A
                     
         
            
         open() will block until both ends are
              open.
         
            
         Note: The "sender" transmits one bit of information (as in the similar example that used signals) by either writing or not. This approach is more subtle than necessary since the pipe can be used to transmit information more directly.
         
            
         
         
            
         Note: With this protocol B1 will always be completed before A1 (which is not required).