pipe()

int pipe(int pfd[2]);

Pipe Communication Flow & Behavior

  1. Parent writes to pipe (write(pfd[1], ...)).
  2. Child reads from pipe (read(pfd[0], ...)).
  3. Data is transferred in a unidirectional manner (one writes, the other reads).
  4. read() blocks if no data is available.
  5. write() blocks if the pipe buffer is full.
  6. If all write ends are closedread() returns 0 (EOF).
  7. If all read ends are closedwrite() triggers SIGPIPE, terminating the process.
  8. Processes exit using exit(0) after completing communication.

Pipe Buffer & Non-Blocking Mode