pipe(3)

DESCRIPTION

Creates an anonymous pipe and stores its read end in fds[0] and write end in fds[1]. The pipe buffer is 4096 bytes.

SYNOPSIS

#include <unistd.h>

int pipe(int fds[2]);

RETURN VALUE

  • Returns zero, or -1 and sets errno.

ERRORS

  • -EFAULT
    • Fds is not writable for two descriptor values.
  • -ESRCH
    • There is no current process.
  • -ENOMEM
    • The pipe object or endpoint descriptors cannot be allocated.

NOTES

An empty pipe read waits while a writer remains; closing the last writer completes a waiting read with zero.