FIFO
Pietro Paolini
P.Paolini at ext.adbglobal.com
Thu Nov 29 04:29:18 EST 2012
-----Original Message-----
From: Victor Buciuc [mailto:victor.buciuc at gmail.com]
Sent: giovedì 29 novembre 2012 10:26
To: Pietro Paolini
Cc: Bernd Petrovitsch; kernelnewbies at kernelnewbies.org
Subject: Re: FIFO
On Thu, Nov 29, 2012 at 11:07 AM, Pietro Paolini <P.Paolini at ext.adbglobal.com> wrote:
> 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.
>
>
I guess what you want is an asynchronous way to react to a request.
A simpler way may be to install a signal handler for SIGUSR1 or
SIGUSR2 and dump the stats in known place.
Or if you really wanna use a pipe you can do a asynchronous read on the pipe and do the stats dumping in the callback.
Regards,
Victor.
Thanks for our answer, I am close to catch the point, that's
> Or if you really wanna use a pipe you can do a asynchronous read on the pipe and do the stats dumping in the callback.
How can I do " do the stats dumping in the callback", could you provide me an example link?
Pietro.
More information about the Kernelnewbies
mailing list