Files
oldlinux-files/Minix/2.0.0/wwwman/man2/pipe.2.html
2024-02-19 00:21:39 -05:00

128 lines
2.6 KiB
HTML

<HTML>
<HEAD>
<TITLE>pipe(2)</TITLE>
</HEAD>
<BODY>
<H1>pipe(2)</H1>
<HR>
<PRE>
</PRE>
<H2>NAME</H2><PRE>
pipe - create an interprocess communication channel
</PRE>
<H2>SYNOPSIS</H2><PRE>
<STRONG>#include</STRONG> <STRONG>&lt;unistd.h&gt;</STRONG>
<STRONG>int</STRONG> <STRONG>pipe(int</STRONG> <EM>fildes</EM><STRONG>[2])</STRONG>
</PRE>
<H2>DESCRIPTION</H2><PRE>
The <STRONG>pipe</STRONG> 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 <EM>fildes</EM>[1] up to PIPE_MAX bytes of
data are buffered before the writing process is suspended. A read using
the descriptor <EM>fildes</EM>[0] will pick up the data.
PIPE_MAX equals 7168 under Minix, but note that most systems use 4096.
It is assumed that after the pipe has been set up, two (or more)
cooperating processes (created by subsequent <STRONG>fork</STRONG> calls) will pass data
through the pipe with <STRONG>read</STRONG> and <STRONG>write</STRONG> 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.
The signal SIGPIPE is generated if a write on a pipe with only one end is
attempted.
</PRE>
<H2>RETURN VALUE</H2><PRE>
The function value zero is returned if the pipe was created; -1 if an
error occurred.
</PRE>
<H2>ERRORS</H2><PRE>
The <STRONG>pipe</STRONG> call will fail if:
[EMFILE] Too many descriptors are active.
[ENFILE] The system file table is full.
[ENOSPC] The pipe file system (usually the root file system) has no
free inodes.
[EFAULT] The <EM>fildes</EM> buffer is in an invalid area of the process's
address space.
</PRE>
<H2>SEE ALSO</H2><PRE>
<STRONG><A HREF="../man1/sh.1.html">sh(1)</A></STRONG>, <STRONG><A HREF="../man2/read.2.html">read(2)</A></STRONG>, <STRONG><A HREF="../man2/write.2.html">write(2)</A></STRONG>, <STRONG><A HREF="../man2/fork.2.html">fork(2)</A></STRONG>.
</PRE>
<H2>NOTES</H2><PRE>
Writes may return ENOSPC errors if no pipe data can be buffered, because
the pipe file system is full.
</PRE>
<H2>BUGS</H2><PRE>
Should more than PIPE_MAX bytes be necessary in any pipe among a loop of
processes, deadlock will occur.
</PRE>
</BODY>
</HTML>