I want to output logger information into FIFO file. My application can run for months. My question is what happens to FIFO file when there is one side constantly writing to it and nobody on the other side reading from it?
Will it eventually stuck, overflow, reset, will it take all OS's RAM?
Create the FIFO w/ mkfifo. Create two processes, a writer and a reader.
Open the FIFO for write, which will block because there's no reader. When it unblocks, write to stderr that it's awake, and then periodically write some bytes to it, and log each write.
Run a reader process, have it sleep a bit, and have it read, say, 10 times, dumping what it reads. Then it should close the fifo and terminate.
What you SHOULD see, according to Stevens APUE, is that the write should cause SIGPIPE to be generated.
Here's an example:
I've run this on a couple of systems, and I'm sure there are issues with it (for example, one shouldn't use fprintf from a signal handler...).
You should also know about PIPE_BUF, the guaranteed minimum number of bytes that can be written. Implementations vary on this.
There are no partial writes to a pipe when the requested size of the buffer is greater than available space. Instead -1 is returned by write with errno set to EAGAIN.
Finally, for high performance messaging or IPC, pipes/FIFOs are not a great choice.
Because there is no guarantee of atomicity, multiple readers on a single pipe can have issues.
Last edited by jim mcnamara; 06-30-2009 at 11:17 AM..
Reason: spell
Hi all,
First of all, sorry for the pastebin link. The code tags aren't working for me.
#!/bin/bash # while-menu-dialog: a menu driven - Pastebin.com
This is a channel "changer" shell script i'm working on. It uses dialog to display the menus.
It... (3 Replies)
Hello ,
I am working on unix FIFO IPC. i have a doubt regarding that.
If the fifo is updated(write()) through one process....can we able to send any signal that fifo is updated and ready to get read...to other process.?? (0 Replies)
Dear friends
i'm want to implement a program which one file is split into fragments by the server (by some random size) and sent to some processes, so these processes get randomly the fragments of the original file from the server, then the downloader randomly connects to some of these processes... (0 Replies)
Hello C programming fellows!!!
I'm doing a program with multiple threads in gnu/linux, ubuntu for beeing precise...
This program consist in multiple threads, as logical each thread do different things and communicate to each other using IPC.
The problem is that in "process 1" I have a... (1 Reply)
hi, my problem is
i have 10 thread for produces double two dimensional array these will produces 2d array 400 times ,then i have a thread to takes a two dimensional array then it inverse , and most 10 array can be in the fifo , and threads given takes one by one, now my problem is , i cant... (0 Replies)
Hello,
I have a FIFO which i would like to open O_WDWR | O_NONBLOCK | O_ASYNC and have a SIGIO signal generated when there is input on the FIFO, but there a re a bunch of bugs surrounding this (like for instance i read somewhere that you have to set O_ASYNC with fcntl etc.
is this even... (0 Replies)
Hi ,
I m beginner for Unix and i want to use FIFO in my 2 Scripts . I want 1 script to read data from FIFO and other will write into FIFO.
Despite reading so many articles/posts i am still unable sunchronize my scripts.
My doubts are
1> Do We require both scripts as daemons to use... (0 Replies)
hi, I have a problem. I've done a lil program which gets from the server the given persons username a personal folder. I made it with a pipe calling popen with a command, but how can i make the same thing using fifo. I make the fifo with mkfifo() func. and than what. How do I tell the sertver using... (3 Replies)
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... (1 Reply)
Hi All
L2000-44
HP-UX 11.00
I am attempting to setup a FIFO over NFS. Directing and reading from the FIFO works fine on the local machine - however when I direct to the FIFO from a server which has the directory NFS mounted it does not work. The a process to read from the FIFO on the local... (2 Replies)