The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Doubts on FIFO Akshay UNIX for Dummies Questions & Answers 0 06-06-2008 07:56 AM
how to use fifo atticus High Level Programming 3 06-05-2006 10:15 AM
FIFO Pipes tej.buch UNIX for Advanced & Expert Users 4 02-11-2006 02:01 AM
FIFO over NFS saabir UNIX for Advanced & Expert Users 2 08-06-2003 08:03 AM
Pipe & fifo.... M3xican High Level Programming 4 07-20-2002 07:22 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-29-2004
runawayNinja runawayNinja is offline
Registered User
  
 

Join Date: Mar 2004
Posts: 9
FIFO issue

hello i am making a client server program
that communicates via FIFOS and i cannot get it to not hang
i also am forking exec-ing the client from the server

my logic (i will spare you the code )
in the server

i make two fifos in my server my file permissions
are 0644

i then open both with O_RDWR

i then fork and exec the client

inside the client

i open two fifos both with O_RDWR

then begin a while loop to write and read from the server



i understand that a FIFO hangs until a read has established itself
but that is why i have the RDWR flag instead of read and write

my questions are

should i fork/exec first?

do i need to mkfifos in the client as well
even tho i am forking and execing

can someone offer some insight i would really appreciate
this has been a thorn in myside
  #2 (permalink)  
Old 04-29-2004
Neo's Avatar
Neo Neo is offline Forum Staff  
Administrator
  
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 6,680
Quote:
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 multiple pro cesses for reading or writing. When processes are exchanging data via the FIFO, the kernel passes all data internally without writing 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 reference 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 non-blocking mode. In this case, opening for read only will succeed even if noone 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 non-blocking mode. POSIX leaves this behaviour 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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:43 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0