* Show application performance/errors from pseudo file
@ 2014-10-16 19:50 Daniel Hilst Selli
2014-10-16 20:00 ` mspiegelmock
[not found] ` <CAMvDr+T54gR3APzCOyZczvCTZs=FvHhsCA0VkZAVJR3BQdeT+w@mail.gmail.com>
0 siblings, 2 replies; 6+ messages in thread
From: Daniel Hilst Selli @ 2014-10-16 19:50 UTC (permalink / raw)
To: linux-c-programming
I'm writing a new application and would be nice to have a pseudo file showing its status, just the way that procfs does with kernel.
I'm looking for sugestions, I want to `cat' files contents and have something similar to /proc/meminfo
First I think using named pipes, but, AFAIK, pipes would retain data writed until someone read it, what I thought is a kind of read
hook that only show data when asked for. Here are a few requisites,
- Don't retain data
- Don't generate disk I/O
- Vanish when application stops
- Work with a simple cat or something similar..
With that in mind I think about using unix domain sockets.. it seems to fit all requisites, for
the fourth requisite I could use netcat, that is almost cat,
Cheers
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Show application performance/errors from pseudo file 2014-10-16 19:50 Show application performance/errors from pseudo file Daniel Hilst Selli @ 2014-10-16 20:00 ` mspiegelmock [not found] ` <CAMvDr+T54gR3APzCOyZczvCTZs=FvHhsCA0VkZAVJR3BQdeT+w@mail.gmail.com> 1 sibling, 0 replies; 6+ messages in thread From: mspiegelmock @ 2014-10-16 20:00 UTC (permalink / raw) Cc: linux-c-programming I’m no expert but I believe you’d need a kernel module to create the char device, then have your application talk to it somehow? http://stackoverflow.com/questions/5970595/create-a-device-node-in-code On Oct 16, 2014, at 12:50 PM, Daniel Hilst Selli <danielhilst@gmail.com> wrote: > I'm writing a new application and would be nice to have a pseudo file showing its status, just the way that procfs does with kernel. > I'm looking for sugestions, I want to `cat' files contents and have something similar to /proc/meminfo > > First I think using named pipes, but, AFAIK, pipes would retain data writed until someone read it, what I thought is a kind of read > hook that only show data when asked for. Here are a few requisites, > > - Don't retain data > - Don't generate disk I/O > - Vanish when application stops > - Work with a simple cat or something similar.. > > With that in mind I think about using unix domain sockets.. it seems to fit all requisites, for > the fourth requisite I could use netcat, that is almost cat, > > Cheers > -- > To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <CAMvDr+T54gR3APzCOyZczvCTZs=FvHhsCA0VkZAVJR3BQdeT+w@mail.gmail.com>]
* Re: Show application performance/errors from pseudo file [not found] ` <CAMvDr+T54gR3APzCOyZczvCTZs=FvHhsCA0VkZAVJR3BQdeT+w@mail.gmail.com> @ 2014-10-16 20:31 ` Yichao Yu 2014-10-17 18:59 ` Daniel Hilst Selli 0 siblings, 1 reply; 6+ messages in thread From: Yichao Yu @ 2014-10-16 20:31 UTC (permalink / raw) To: Daniel Hilst Selli; +Cc: linux-c-programming@vger.kernel.org Resend as plain text. On Thu, Oct 16, 2014 at 4:01 PM, Yichao Yu <yyc1992@gmail.com> wrote: > > > On Thu, Oct 16, 2014 at 3:50 PM, Daniel Hilst Selli <danielhilst@gmail.com> > wrote: >> >> I'm writing a new application and would be nice to have a pseudo file >> showing its status, just the way that procfs does with kernel. >> I'm looking for sugestions, I want to `cat' files contents and have >> something similar to /proc/meminfo >> >> First I think using named pipes, but, AFAIK, pipes would retain data >> writed until someone read it, what I thought is a kind of read >> hook that only show data when asked for. Here are a few requisites, >> >> - Don't retain data >> - Don't generate disk I/O >> - Vanish when application stops >> - Work with a simple cat or something similar.. > > > You should have a look at fuse[1]. > > [1] http://fuse.sourceforge.net/ > >> >> >> With that in mind I think about using unix domain sockets.. it seems to >> fit all requisites, for >> the fourth requisite I could use netcat, that is almost cat, >> >> Cheers >> -- >> To unsubscribe from this list: send the line "unsubscribe >> linux-c-programming" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Show application performance/errors from pseudo file 2014-10-16 20:31 ` Yichao Yu @ 2014-10-17 18:59 ` Daniel Hilst Selli 2014-10-17 19:00 ` Daniel Hilst Selli 0 siblings, 1 reply; 6+ messages in thread From: Daniel Hilst Selli @ 2014-10-17 18:59 UTC (permalink / raw) Cc: linux-c-programming@vger.kernel.org On 10/16/2014 05:31 PM, Yichao Yu wrote: > Resend as plain text. > > On Thu, Oct 16, 2014 at 4:01 PM, Yichao Yu <yyc1992@gmail.com> wrote: >> >> >> On Thu, Oct 16, 2014 at 3:50 PM, Daniel Hilst Selli <danielhilst@gmail.com> >> wrote: >>> >>> I'm writing a new application and would be nice to have a pseudo file >>> showing its status, just the way that procfs does with kernel. >>> I'm looking for sugestions, I want to `cat' files contents and have >>> something similar to /proc/meminfo >>> >>> First I think using named pipes, but, AFAIK, pipes would retain data >>> writed until someone read it, what I thought is a kind of read >>> hook that only show data when asked for. Here are a few requisites, >>> >>> - Don't retain data >>> - Don't generate disk I/O >>> - Vanish when application stops >>> - Work with a simple cat or something similar.. >> >> >> You should have a look at fuse[1]. >> >> [1] http://fuse.sourceforge.net/ >> >>> >>> >>> With that in mind I think about using unix domain sockets.. it seems to >>> fit all requisites, for >>> the fourth requisite I could use netcat, that is almost cat, >>> >>> Cheers >>> -- >>> To unsubscribe from this list: send the line "unsubscribe >>> linux-c-programming" in >>> the body of a message to majordomo@vger.kernel.org >>> More majordomo info at http://vger.kernel.org/majordomo-info.html >> >> Seems god, a little overkill for so simple stuff but adds nice features, I'm taking a look on further options.. Cheers ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Show application performance/errors from pseudo file 2014-10-17 18:59 ` Daniel Hilst Selli @ 2014-10-17 19:00 ` Daniel Hilst Selli 2014-10-23 19:09 ` Daniel Hilst Selli 0 siblings, 1 reply; 6+ messages in thread From: Daniel Hilst Selli @ 2014-10-17 19:00 UTC (permalink / raw) To: linux-c-programming@vger.kernel.org On 10/17/2014 03:59 PM, Daniel Hilst Selli wrote: > On 10/16/2014 05:31 PM, Yichao Yu wrote: >> Resend as plain text. >> >> On Thu, Oct 16, 2014 at 4:01 PM, Yichao Yu <yyc1992@gmail.com> wrote: >>> >>> >>> On Thu, Oct 16, 2014 at 3:50 PM, Daniel Hilst Selli <danielhilst@gmail.com> >>> wrote: >>>> >>>> I'm writing a new application and would be nice to have a pseudo file >>>> showing its status, just the way that procfs does with kernel. >>>> I'm looking for sugestions, I want to `cat' files contents and have >>>> something similar to /proc/meminfo >>>> >>>> First I think using named pipes, but, AFAIK, pipes would retain data >>>> writed until someone read it, what I thought is a kind of read >>>> hook that only show data when asked for. Here are a few requisites, >>>> >>>> - Don't retain data >>>> - Don't generate disk I/O >>>> - Vanish when application stops >>>> - Work with a simple cat or something similar.. >>> >>> >>> You should have a look at fuse[1]. >>> >>> [1] http://fuse.sourceforge.net/ >>> >>>> >>>> >>>> With that in mind I think about using unix domain sockets.. it seems to >>>> fit all requisites, for >>>> the fourth requisite I could use netcat, that is almost cat, >>>> >>>> Cheers >>>> -- >>>> To unsubscribe from this list: send the line "unsubscribe >>>> linux-c-programming" in >>>> the body of a message to majordomo@vger.kernel.org >>>> More majordomo info at http://vger.kernel.org/majordomo-info.html >>> >>> > > Seems god, a little overkill for so simple stuff but adds nice features, I'm taking > a look on further options.. > > Cheers good* ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Show application performance/errors from pseudo file 2014-10-17 19:00 ` Daniel Hilst Selli @ 2014-10-23 19:09 ` Daniel Hilst Selli 0 siblings, 0 replies; 6+ messages in thread From: Daniel Hilst Selli @ 2014-10-23 19:09 UTC (permalink / raw) To: linux-c-programming@vger.kernel.org On 10/17/2014 04:00 PM, Daniel Hilst Selli wrote: > On 10/17/2014 03:59 PM, Daniel Hilst Selli wrote: >> On 10/16/2014 05:31 PM, Yichao Yu wrote: >>> Resend as plain text. >>> >>> On Thu, Oct 16, 2014 at 4:01 PM, Yichao Yu <yyc1992@gmail.com> wrote: >>>> >>>> >>>> On Thu, Oct 16, 2014 at 3:50 PM, Daniel Hilst Selli <danielhilst@gmail.com> >>>> wrote: >>>>> >>>>> I'm writing a new application and would be nice to have a pseudo file >>>>> showing its status, just the way that procfs does with kernel. >>>>> I'm looking for sugestions, I want to `cat' files contents and have >>>>> something similar to /proc/meminfo >>>>> >>>>> First I think using named pipes, but, AFAIK, pipes would retain data >>>>> writed until someone read it, what I thought is a kind of read >>>>> hook that only show data when asked for. Here are a few requisites, >>>>> >>>>> - Don't retain data >>>>> - Don't generate disk I/O >>>>> - Vanish when application stops >>>>> - Work with a simple cat or something similar.. >>>> >>>> >>>> You should have a look at fuse[1]. >>>> >>>> [1] http://fuse.sourceforge.net/ >>>> >>>>> >>>>> >>>>> With that in mind I think about using unix domain sockets.. it seems to >>>>> fit all requisites, for >>>>> the fourth requisite I could use netcat, that is almost cat, >>>>> >>>>> Cheers >>>>> -- >>>>> To unsubscribe from this list: send the line "unsubscribe >>>>> linux-c-programming" in >>>>> the body of a message to majordomo@vger.kernel.org >>>>> More majordomo info at http://vger.kernel.org/majordomo-info.html >>>> >>>> >> >> Seems god, a little overkill for so simple stuff but adds nice features, I'm taking >> a look on further options.. >> >> Cheers > good* Looking further I found that named pipes will block on open() calls, until the other end open it too. So I still can implement this with named pipes. Here is the pseudo code implementation I use. (Yes I'm using threads) void *stats_handler(void *unused) { for (;;) { int fd = open(FIFO_PATH, O_WRONLY); /* should block here */ /* handle open error */ write(fd, statistics_buffer, statistics_buffer_len); close(fd); sleep(1); /* avoid flooders :-P */ } } void stats_init(void) { pthread_t stat_id; mkfifo(FIFO_PATH, 0755); /* handle mkfifo errors */ pthread_create(&stat_id, NULL, stats_handler, NULL); } int main(void) { ... stats_init(); ... } After that I can just `cat FIFO_PATH' to see my statistics :D Thanks for all and best regards! ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-10-23 19:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-16 19:50 Show application performance/errors from pseudo file Daniel Hilst Selli
2014-10-16 20:00 ` mspiegelmock
[not found] ` <CAMvDr+T54gR3APzCOyZczvCTZs=FvHhsCA0VkZAVJR3BQdeT+w@mail.gmail.com>
2014-10-16 20:31 ` Yichao Yu
2014-10-17 18:59 ` Daniel Hilst Selli
2014-10-17 19:00 ` Daniel Hilst Selli
2014-10-23 19:09 ` Daniel Hilst Selli
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).