Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-15-2005, 12:59 PM   #1
Registered: Feb 2004
Location: Athens, Greece
Distribution: Gentoo,FreeBSD, Debian
Posts: 705

Rep: Reputation: 30
about pipes

lets say i create a pipe with:
ints fds[2];
Is fds[0] the STANDARD read end of the pipe and pipe[1[ the STANDARD write end? I have read this, but i have also read these in the same program:
fdopen(pipe[0], "r");
Does that mean that pipe[0] for read and pipe[1] for write are not standard and they are just conventions?
Old 10-15-2005, 01:37 PM   #2
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 42
fds[0] is open for reading and fds[1] is open for writing after you call pipe(). This means that you can call read() and write() on them, respectively.

fdopen() returns a FILE* on which you can fwrite(), fread(), or fprintf(). The mode you pass to fdopen needs to be compatible with the file descriptor you pass it; in this case you must pass fds[0] for reading and fds[1] for writing.

The FILE type is an abstraction over integer file descriptors. The functions which operate on it (fprintf and so on) do some buffering in your program to make it a little faster.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
pipes in python? SciYro Programming 9 08-02-2006 10:35 AM
Question regarding pipes alltime Programming 3 04-15-2005 08:54 PM
devices and pipes siemens Linux - General 1 03-23-2005 04:30 AM
pipes on Suse AdamTheFirst Linux - Software 1 11-04-2004 03:07 PM
Interleaving using pipes AquamaN Programming 1 09-28-2003 05:59 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:33 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration