Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
PIPE(2)			      System Calls Manual		       PIPE(2)

NAME
       pipe - create an	interprocess channel

SYNOPSIS
       pipe(fildes)
       int fildes[2];

DESCRIPTION
       The  pipe system	call creates an	I/O mechanism called a pipe.  The file
       descriptors returned can	be used	in read	and  write  operations.	  When
       the  pipe is written using the descriptor fildes[1] up to 4096 bytes of
       data are	buffered before	the writing process is suspended.  A read  us-
       ing  the	 descriptor  fildes[0]	will  pick up the data.	 Writes	with a
       count of	4096 bytes or less are atomic; no  other  process  can	inter-
       sperse data.

       It  is assumed that after the pipe has been set up, two (or more) coop-
       erating processes (created by subsequent	fork  calls)  will  pass  data
       through the pipe	with read and write calls.

       The  Shell has a	syntax to set up a linear array	of processes connected
       by pipes.

       Read calls on an	empty pipe (no buffered	data) with only	one  end  (all
       write file descriptors closed) returns an end-of-file.

SEE ALSO
       sh(1), fork(2), read(2),	write(2)

ERRORS
       The pipe	call will fail if:

       [EMFILE]		   Too many descriptors	are active.

       [EFAULT]		   The	fildes	buffer	is  in	an invalid area	of the
			   process's allocated address space.

BUGS
       Should more than	4096 bytes be necessary	in any pipe among  a  loop  of
       processes, deadlock will	occur.

ASSEMBLER
       (pipe = 42.)
       sys pipe
       (read file descriptor in	r0)
       (write file descriptor in r1)

3rd Berkeley Distribution					       PIPE(2)

NAME | SYNOPSIS | DESCRIPTION | SEE ALSO | ERRORS | BUGS | ASSEMBLER

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=pipe&sektion=2&manpath=2.9.1+BSD>

home | help