FIFO

Pietro Paolini P.Paolini at ext.adbglobal.com
Thu Nov 29 04:07:25 EST 2012


Hello!

Thanks for your reply, the fact is that I am not writing a device driver but just an user-space program  and I would like implement a technique like /proc/ under a normal directory.

Like /tmp/blahblah

I have a program which take count about some statistics and I want read them "on demand" doing a cat of /tmp/blahblah, I investigate a bit and :

1) FIFO can be a solution but if I am not wrong I need two FIFO, one for say "I want read stats" and another one where write them

2) I could use inotify and write on a file the stats when file under monitoring is opened for read.

In both cases I need two file, I would like instead use one, how can I do that ?

Many many thanks,
Pietro.


-----Original Message-----
From: kernelnewbies-bounces at kernelnewbies.org [mailto:kernelnewbies-bounces at kernelnewbies.org] On Behalf Of Bernd Petrovitsch
Sent: mercoledì 28 novembre 2012 14:06
To: kernelnewbies at kernelnewbies.org
Subject: Re: FIFO

Hi!

On Mit, 2012-11-28 at 09:43 +0000, Pietro Paolini wrote:
[....]
> I would like use a FIFO to implement a pipe which use is quite the 
> same of the /proc/fs (for example the net statistics then just read).

/proc/fs is a directory hereover.

> I would like use the cat command in order to reach the information, like:
> 
> Cat /path/to/pipe
> 
> The problem is that cat expect the EOF of file before exit and stay

That "problem" is the defined behaviour and all programs will behave that way.

>  blocked until that, someone know how can I solve the problem ?

Wherever your driver sends out the data (when user-space read(2)s it), you just return 0 (instead of sleeping/blocking the process) if you are at the end of the output.

Kind regards,
	Bernd
-- 
Bernd Petrovitsch                  Email : bernd at petrovitsch.priv.at
                     LUGA : http://www.luga.at


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



More information about the Kernelnewbies mailing list