Sponsored Content
Full Discussion: Two types of pipes?
Top Forums UNIX for Dummies Questions & Answers Two types of pipes? Post 88106 by Perderabo on Monday 31st of October 2005 05:11:56 PM
Old 10-31-2005
Your first type of pipe actually is a pipe. That is, it is created by the pipe() system call. That system call returns a pair of fd's in an array. You write stuff on fd[1] and read stuff on fd[0]. Pipes persist across both fork() and exec(). You can wind up with several processes writing to fd[1] or reading from fd[0] (not that multiple readers make that much sense). But all processes using the pipe are desended from the process that issued pipe() in the first place (I'm ignoring a very arcane exception here). Mostly though you have one process writing on fd[1] and another process reading from fd[0]. I just checked the Posix standard, and this is all that the standard officially mandates. Virually every modern version of unix implements an extention: writing on fd[0] and reading from fd[1]. This results in two independent data streams. This emulates the behavior of socketpair() and this extension arose on BSD when pipes were implemented as socket styles objects. (The first implementation was a as a screwy file system object.)

Your second style of pipe was originally called a "named pipe". It is politically incorrect to call them "named pipes" today. (Which is exactly why I call them "named pipes".) You are supposed to call them fifos today. (F. I. F. O == first in, first out). It is not possible for named pipes to be bi-directional like a socketpair() style pipe. There is a single data stream. Very often there will be a single reader and multiple writers. The processes need not be closely related to each other nor to the creator of the named pipe. Permission to read and write is controlled by file system permission. Unlike pipes, named pipes must be opened with open(). open() is expensive relative to pipe().

Which one is faster at transferring data depends on your kernel and how you built it. With HP-UX, for example, you can build a kernel that uses Streams-based pipes, but HP-UX does not support Streams-based fifos. This mostly affects non-standard features like using a zero length write to send a zero length message.
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

backup types

can anyone explain me difference between tar and ufsdump commands.............and also i wd like to know the difference between incremental and differential backup......... thx in advance (1 Reply)
Discussion started by: girish_shukla
1 Replies

2. Filesystems, Disks and Memory

associated file types

I have a file of type .for extension .In a guui based unix environment like solaris if I double click on that file a specific program designed by me has to run which takes this file as the parameter and exceutes the program. Can anyone help me? (8 Replies)
Discussion started by: nhk_srd
8 Replies

3. Filesystems, Disks and Memory

PIPEs and Named PIPEs (FIFO) Buffer size

Hello! How I can increase or decrease predefined pipe buffer size? System FreeBSD 4.9 and RedHat Linux 9.0 Thanks! (1 Reply)
Discussion started by: Jus
1 Replies

4. UNIX for Dummies Questions & Answers

mime types

Hi, I am trying to launch an ogg movie from a pdf file which has been produced with pdflatex and \movie {\centerline{\includegraphics {grafiques_xerrades/un_manolo_amb_camera.pdf}}} {hlims_xerrades/XocCumuls.ogg} The switch "externalviewer" makes kpdf launch the default... (5 Replies)
Discussion started by: pau
5 Replies

5. What is on Your Mind?

What Types of Food Do You Like The Most?

On another simple topic, multiple choice answers OK ( you can pick more than one or suggest others - we will add your suggestions to the poll ). What Types of Food Do You Like The Most? (27 Replies)
Discussion started by: Neo
27 Replies

6. Homework & Coursework Questions

Help with using different types of GREP

1. The problem statement, all variables and given/known data: Hey there, I'm brand new to using Unix as I just started a course on it in my University, and I currently working through a worksheet which focuses on the many commands and methods of GREP (I'm working through the terminal command... (11 Replies)
Discussion started by: SilvarHawke
11 Replies

7. Shell Programming and Scripting

Cp -r except certain file types

the following excludes certain directories successfully cp -r probe/!(dir) /destination I want to exclude certain file types and tried unsuccessfully cp -r probe/!(*.avi) /destination (2 Replies)
Discussion started by: tmf
2 Replies

8. Programming

Are These All The Integer Types In C

Hello and Good day, I am currently studying C and I just finished learning about variables mainly those of integer type. I am wondering if the list below are all there is to integer variables and there are still more that i have to learn. Here are the list: Char Short int long long long... (3 Replies)
Discussion started by: split_func0
3 Replies
FIFO(7) 						     Linux Programmer's Manual							   FIFO(7)

NAME
fifo - first-in first-out special file, named pipe DESCRIPTION
A FIFO special file (a named pipe) is similar to a pipe, except that it is accessed as part of the file system. It can be opened by multi- ple processes for reading or writing. When processes are exchanging data via the FIFO, the kernel passes all data internally without writ- ing it to the file system. Thus, the FIFO special file has no contents on the file system; the file system entry merely serves as a refer- ence point so that processes can access the pipe using a name in the file system. The kernel maintains exactly one pipe object for each FIFO special file that is opened by at least one process. The FIFO must be opened on both ends (reading and writing) before data can be passed. Normally, opening the FIFO blocks until the other end is opened also. A process can open a FIFO in nonblocking mode. In this case, opening for read-only will succeed even if no-one has opened on the write side yet, opening for write-only will fail with ENXIO (no such device or address) unless the other end has already been opened. Under Linux, opening a FIFO for read and write will succeed both in blocking and nonblocking mode. POSIX leaves this behavior undefined. This can be used to open a FIFO for writing while there are no readers available. A process that uses both ends of the connection in order to communicate with itself should be very careful to avoid deadlocks. NOTES
When a process tries to write to a FIFO that is not opened for read on the other side, the process is sent a SIGPIPE signal. FIFO special files can be created by mkfifo(3), and are indicated by ls -l with the file type 'p'. SEE ALSO
mkfifo(1), open(2), pipe(2), sigaction(2), signal(2), socketpair(2), mkfifo(3), pipe(7) COLOPHON
This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2008-12-03 FIFO(7)
All times are GMT -4. The time now is 08:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy