Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pipe(2) [v7 man page]

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 using 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) cooperating 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), read(2), write(2), fork(2) DIAGNOSTICS
The function value zero is returned if the pipe was created; -1 if too many files are already open. A signal is generated if a write on a pipe with only one end is attempted. 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) PIPE(2)

Check Out this Related Man Page

pipe(2) 							System Calls Manual							   pipe(2)

Name
       pipe - create an interprocess channel

Syntax
       include <limits.h> /*Definition of PIPE_MAX*/
       pipe(fildes)
       int fildes[2];

Arguments
       fildes	 Passing an address as an array of two integers into the system call.

Description
       The system call creates an I/O mechanism called a pipe.	The file descriptors returned can be used in and operations.  Their integer values
       will be the two lowest available at the time of the function call.  The O_NONBLOCK and FD_CLOEXEC flags will be clear on both file descrip-
       tors.

       When the pipe is written using the descriptor fildes[1], up to PIPE_MAX bytes of data are buffered before the writing process is suspended.
       A read using the descriptor fildes[0] picks up the data.

       It is assumed that after the pipe has been set up, two (or more) cooperating processes (created by subsequent calls) pass data through  the
       pipe with and calls.

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

       For further information on how and calls behave with pipes, see the and reference pages.

       A signal is generated if a write on a pipe with only one end is attempted.

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

       The  underlying	implementation	of  pipes is no longer socket based, but rather implemented through the file system.  Any application that
       needs socket functionality from pipes should use the system call.

Return Values
       The function value zero is returned if the pipe was created; -1 if an error occurred.

Diagnostics
       The call fails if:

       [EMFILE]       Too many descriptors are active.

       [ENFILE]       The system file table is full.

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

Environment
       Differs from the System V definition in that ENFILE is not a possible error condition.

See Also
       sh(1), fork(2), read(2), socketpair(2), write(2)

																	   pipe(2)
Man Page

15 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Overwrite

if i want to pipe output to a file, say, cat abc.dat > abc.txt, how do i make it replace the existing file? (9 Replies)
Discussion started by: Duckman
9 Replies

2. UNIX for Advanced & Expert Users

Can't create more pipe

How can I change the maxnumber of pipes on my workstation? I'm running an EXPECT script that is suppose to start up 32 xterms. But after 18 opened xterm, I get this msg: - couldn't create pipe: too many open files regard, chris (9 Replies)
Discussion started by: uabcbac
9 Replies

3. UNIX for Dummies Questions & Answers

ls -la

Hi All, Can anyone help me how to change the the o/p of ls -la command under any directory in a pipe | delimited format. Thanks, jam (10 Replies)
Discussion started by: jam_prasanna
10 Replies

4. Shell Programming and Scripting

Help with pipe count in a flat file!!!

Hi Friends, I have a flat file and it has 43 columns which means 42 pipes but some records have less number of pipes.Can anyone tell me a command to count the number of pipes in a record and redirect the count to some new file because the flat file has not less than 40,000 records. Thanks... (14 Replies)
Discussion started by: kumarsaravana_s
14 Replies

5. Shell Programming and Scripting

Append line that does not contain pipe to it previous line

Hi All, I have a file which contains data as below When we see no pipe character in the line. append those lines to the previous line with pipe character till we get the next line with pipe character with ~(concat with ~) Input file looks like: 1080530944|001|john.l.bonner|Acknowledge|CN... (11 Replies)
Discussion started by: ainuddin
11 Replies

6. Shell Programming and Scripting

Subsitute from a position till end of line.

Hi, Having a following file's content, lets say: ABC|ANA|LDJ|||||DKD|||||| AJJ|KKDD||KKDK|||||||||||| KKD||KD|||LLLD||||LLD||||| Problem: Need to replace pipes from 8th occurrence of pipe till end. so the result should be: ABC|ANA|LDJ|||||DKD AJJ|KKDD||KKDK|||| ------- ------- ... (12 Replies)
Discussion started by: _Noprofi
12 Replies

7. Shell Programming and Scripting

Awk to Search and Replace inside the pipe "|"

Hi, Anyone can help me on how to replace the qoutes inside the pipe | in my Text File like belows; "AAAA"|"Test "1-A""|"Test AAAA"|"This is A" "BBBB"|"Test "1-B""|"Test BBBB"|"This is B" "CCCC"|"My Test C"|"Test "CCCC""|"This is C" The output I need like belows; "AAAA"|"Test 1-A"|"Test... (12 Replies)
Discussion started by: fspalero
12 Replies

8. Homework & Coursework Questions

While loop...

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am trying to read a file that was made using VI that consists of a user login name, full name, phone number and... (15 Replies)
Discussion started by: csharp100
15 Replies

9. Programming

Multiple children and single pipe

Greetings everyone, I need a bit of help in solving the following problem: I'm given an array of numbers and I have to compute the sum of the array elements using n processes, and the inter process communication has to be done with pipes(one pipe, to be exact). I managed to solve the problem... (14 Replies)
Discussion started by: ephesos
14 Replies

10. UNIX for Advanced & Expert Users

write failed: Broken pipe

The "write failed: Broken pipe" message is reported by the file sending PC which run my writed network device driver while 500MB or 900MB is sended! What does the message mean? Does this mean there is a bug in my driver? li,kunlun (11 Replies)
Discussion started by: liklstar
11 Replies

11. Shell Programming and Scripting

Reading data from file using awk

I have a file as below. It contains two data sets separated by >. I want to pipe each data set to another program called psxy. How can I get the different records Have started doing as follows but it only passes the first data set awk 'BEGIN {RS=">"};{print $0}' p.dat cat p.dat... (12 Replies)
Discussion started by: kristinu
12 Replies

12. Shell Programming and Scripting

To remove duplicates from pipe delimited file

Hi some one please help me to remove duplicates from a pipe delimited file based on first two columns. 123|asdf|sfsd|qwrer 431|yui|qwer|opws 123|asdf|pol|njio Here My first record and last record are duplicates.As per my requirement I want all the latest records into one file. I want the... (12 Replies)
Discussion started by: ginrkf
12 Replies

13. Shell Programming and Scripting

Would pipe work better with this command

Hi again, have a script that I would like run, but before I can run it I need to strip out the windows \r end of lines. I have put the command into a text file and set the command to run every 10 seconds the coomand I use to do this is while sleep 10; do... (15 Replies)
Discussion started by: Paul Walker
15 Replies

14. UNIX for Dummies Questions & Answers

Named pipe hanging?

Ok, I can't seem to figure this out or find anything on the web about this. I'm on Sun Solaris, UNIX. I have the following test script: #!/bin/ksh touch test.file LOG=./tmp.log rm -f ${LOG} PIPE=./tmp.pipe mkfifo ${PIPE} trap "rm -f ${PIPE}" EXIT tee -a ${LOG} < ${PIPE} & ... (17 Replies)
Discussion started by: Ditto
17 Replies

15. Shell Programming and Scripting

Ksh: run commands from pipe

I create commands within a pipe and finally want them to be executed instead of being displayed on the screen. What is the last stage in this pipe? I found by guessing that "ksh" is working, but is this the best to use here? It boils down to this: echo "print Hello World!"| kshWhat is the... (15 Replies)
Discussion started by: Cochise
15 Replies