niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » Unix internals
difference between normal file and named pipe file
Post new topic   Reply to topic Page 1 of 1 [11 Posts] View previous topic :: View next topic
Author Message
ramu
*nix forums beginner


Joined: 13 Jan 2006
Posts: 25

PostPosted: Fri Jun 09, 2006 10:04 am    Post subject: difference between normal file and named pipe file Reply with quote

HI,
will anyone let me know the differences between the normal unix
file and named pipe file?

Regards
Back to top
Barry Margolin
*nix forums Guru


Joined: 24 Feb 2005
Posts: 323

PostPosted: Fri Jun 09, 2006 1:02 pm    Post subject: Re: difference between normal file and named pipe file Reply with quote

In article <1149847461.686160.120590@j55g2000cwa.googlegroups.com>,
"ramu" <ramu.ask@gmail.com> wrote:

Quote:
HI,
will anyone let me know the differences between the normal unix
file and named pipe file?

A normal file is a bunch of data sitting on disk.

A named pipe is a way for two processes to connect to each other and
send data directly.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Back to top
colonel_hack@yahoo.com
*nix forums beginner


Joined: 26 Jul 2005
Posts: 5

PostPosted: Fri Jun 09, 2006 3:28 pm    Post subject: Re: difference between normal file and named pipe file Reply with quote

Quote:
In article <1149847461.686160.120590@j55g2000cwa.googlegroups.com>,
"ramu" <ramu.ask@gmail.com> wrote:

HI,
will anyone let me know the differences between the normal unix
file and named pipe file?

A file keeps all the data until deleted/overwritten while iiuc a named
pipe dumps the data after it is read. So a temp file could keep growing
and fill a file system, but a named pipe is less likey to for, say, long
running processes.

3ch
Back to top
Andrew Smallshaw
*nix forums beginner


Joined: 23 Feb 2005
Posts: 26

PostPosted: Mon Jun 12, 2006 4:44 pm    Post subject: Re: difference between normal file and named pipe file Reply with quote

On 2006-06-09, colonel_hack@yahoo.com <colonel_hack@yahoo.com> wrote:
Quote:

A file keeps all the data until deleted/overwritten while iiuc a named
pipe dumps the data after it is read. So a temp file could keep growing
and fill a file system, but a named pipe is less likey to for, say, long
running processes.

I'm not sure I understand this - a write to a named pipe will block if
there is no corresponding process reading from the pipe, usually
blocking the whole process until there's a reader. This in itself is
can be quite a useful shell hack - it allows to send a signal between
two processes, potentially owned by different users, without root
permissions being needed.

--
Andrew Smallshaw
andrews@sdf.lonestar.org
Back to top
colonel_hack@yahoo.com
*nix forums beginner


Joined: 26 Jul 2005
Posts: 5

PostPosted: Tue Jun 13, 2006 9:41 pm    Post subject: Re: difference between normal file and named pipe file Reply with quote

~On Mon, 12 Jun 2006, Andrew Smallshaw wrote:

Quote:
On 2006-06-09, colonel_hack@yahoo.com <colonel_hack@yahoo.com> wrote:

A file keeps all the data until deleted/overwritten while iiuc a named
pipe dumps the data after it is read. So a temp file could keep growing
and fill a file system, but a named pipe is less likey to for, say, long
running processes.

I'm not sure I understand this - a write to a named pipe will block if
there is no corresponding process reading from the pipe, usually
blocking the whole process until there's a reader. This in itself is
can be quite a useful shell hack - it allows to send a signal between
two processes, potentially owned by different users, without root
permissions being needed.

I'm not sure what part you don't understand (perhaps I've said something
wrong) but:
An open for writing to a named pipe will block if there is no process with
the file open for reading (and vice versa). But it dosen't have to be
actively reading for the writer to write, so the file can still grow. I
think there is also some smaller limit that for a normal file. But the
blocking scheme is also an important difference.

3ch
Back to top
Barry Margolin
*nix forums Guru


Joined: 24 Feb 2005
Posts: 323

PostPosted: Wed Jun 14, 2006 4:06 am    Post subject: Re: difference between normal file and named pipe file Reply with quote

In article <20060613083148.E733@nonsuch.ronnet.moc>,
colonel_hack@yahoo.com wrote:

Quote:
~On Mon, 12 Jun 2006, Andrew Smallshaw wrote:

On 2006-06-09, colonel_hack@yahoo.com <colonel_hack@yahoo.com> wrote:

A file keeps all the data until deleted/overwritten while iiuc a named
pipe dumps the data after it is read. So a temp file could keep growing
and fill a file system, but a named pipe is less likey to for, say, long
running processes.

I'm not sure I understand this - a write to a named pipe will block if
there is no corresponding process reading from the pipe, usually
blocking the whole process until there's a reader. This in itself is
can be quite a useful shell hack - it allows to send a signal between
two processes, potentially owned by different users, without root
permissions being needed.

I'm not sure what part you don't understand (perhaps I've said something
wrong) but:
An open for writing to a named pipe will block if there is no process with
the file open for reading (and vice versa). But it dosen't have to be
actively reading for the writer to write, so the file can still grow.

What file? There's no file associated with a named pipe, it's just a
kernel connection between the two processes.

Quote:
I
think there is also some smaller limit that for a normal file. But the
blocking scheme is also an important difference.

There's typically a buffer of about 4KB in the kernel. So if the writer
writes faster than the reader reads, the writer will block when it gets
4K ahead of the reader.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Back to top
ramu
*nix forums beginner


Joined: 13 Jan 2006
Posts: 25

PostPosted: Wed Jun 14, 2006 7:46 am    Post subject: Re: difference between normal file and named pipe file Reply with quote

Well. Thanks for your answers. The differences what you have given are
functional. Can anyone tell me the implementation level differencs
between normal unix files and named pipe files?

Regards
Back to top
colonel_hack@yahoo.com
*nix forums beginner


Joined: 26 Jul 2005
Posts: 5

PostPosted: Wed Jun 14, 2006 4:30 pm    Post subject: Re: difference between normal file and named pipe file Reply with quote

On Wed, 14 Jun 2006, Barry Margolin wrote:

Quote:
What file? There's no file associated with a named pipe, it's just a
kernel connection between the two processes.
A -named- pipe? Per Maurice Bach in The Design of the Unix operating

system: "A named pipe is a file whose semantics are the same as those of
an unnamed pipe, except it has a directory entry and is accessed by a path
name." Also he says the size limit is set by the use of only direct blocks
of the inode but he is talking about System V

Under FreeBSD (and similar under Fedora core 3):
%ls
%
%mkfifo joe
%ls
joe
%echo "1234567890" > joe

hangs until I do
%cat joe
1234567890
%
in another terminal.
and
%ls -i
147374 joe
show it has an inode

Quote:
There's typically a buffer of about 4KB in the kernel. So if the writer
writes faster than the reader reads, the writer will block when it gets
4K ahead of the reader.
Perhaps in modern unices the name is stored in the file system but data

in buffers, but it has a directory entry and and inode. That is what I
meant by calling it a file anyway.

This has encouraged me read up on named pipes though :-)

3ch
Back to top
Barry Margolin
*nix forums Guru


Joined: 24 Feb 2005
Posts: 323

PostPosted: Thu Jun 15, 2006 12:04 am    Post subject: Re: difference between normal file and named pipe file Reply with quote

In article <20060614084958.A81933@nonsuch.ronnet.moc>,
colonel_hack@yahoo.com wrote:

Quote:
On Wed, 14 Jun 2006, Barry Margolin wrote:

What file? There's no file associated with a named pipe, it's just a
kernel connection between the two processes.
A -named- pipe? Per Maurice Bach in The Design of the Unix operating
system: "A named pipe is a file whose semantics are the same as those of
an unnamed pipe, except it has a directory entry and is accessed by a path
name." Also he says the size limit is set by the use of only direct blocks
of the inode but he is talking about System V

Under FreeBSD (and similar under Fedora core 3):
%ls
%
%mkfifo joe
%ls
joe
%echo "1234567890" > joe

hangs until I do
%cat joe
1234567890
%
in another terminal.
and
%ls -i
147374 joe
show it has an inode

There's typically a buffer of about 4KB in the kernel. So if the writer
writes faster than the reader reads, the writer will block when it gets
4K ahead of the reader.
Perhaps in modern unices the name is stored in the file system but data
in buffers, but it has a directory entry and and inode. That is what I
meant by calling it a file anyway.

If everything that has a directory entry is a file, then yes it's a
file, and so is a tty device, tape drive, etc. I was using the term in
the more traditional sense to mean a collection of non-volatile data on
some storage medium.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Back to top
colonel_hack@yahoo.com
*nix forums beginner


Joined: 26 Jul 2005
Posts: 5

PostPosted: Thu Jun 15, 2006 4:46 am    Post subject: Re: difference between normal file and named pipe file Reply with quote

On Wed, 14 Jun 2006, Barry Margolin wrote:
Quote:

If everything that has a directory entry is a file, then yes it's a
file, and so is a tty device, tape drive, etc. I was using the term in
the more traditional sense to mean a collection of non-volatile data on
some storage medium.

More traditional outside of unix, but it is the standard unix terminology.
"Everything is a file" and all that.

3ch
Back to top
Barry Margolin
*nix forums Guru


Joined: 24 Feb 2005
Posts: 323

PostPosted: Thu Jun 15, 2006 12:51 pm    Post subject: Re: difference between normal file and named pipe file Reply with quote

In article <20060614163845.R7173@nonsuch.ronnet.moc>,
colonel_hack@yahoo.com wrote:

Quote:
On Wed, 14 Jun 2006, Barry Margolin wrote:

If everything that has a directory entry is a file, then yes it's a
file, and so is a tty device, tape drive, etc. I was using the term in
the more traditional sense to mean a collection of non-volatile data on
some storage medium.

More traditional outside of unix, but it is the standard unix terminology.
"Everything is a file" and all that.

Yeah, I never was a big fan of Unix's term "special file".

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [11 Posts] View previous topic :: View next topic
The time now is Tue Dec 02, 2008 12:58 pm | All times are GMT
navigation Forum index » Programming » Unix internals
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Running php file everyday on scheduled time sachin PHP 1 Fri Jul 21, 2006 12:49 pm
No new posts Regarding thesaurus iso file Srikanth modules 0 Fri Jul 21, 2006 10:42 am
No new posts how can i get a file descriptor not used? mars system 0 Fri Jul 21, 2006 7:41 am
No new posts small GTK "Open file" dialog David Siroky Debian 0 Fri Jul 21, 2006 7:30 am
No new posts Trouble Declaring 3D Array in Header File free2klim C++ 1 Fri Jul 21, 2006 4:07 am

Loans | Arizona Flags | Credit Cards | Loans | Mobile Phone
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.3447s ][ Queries: 16 (0.2357s) ][ GZIP on - Debug on ]