Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.embedded > #438
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.straub-nv.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!news.dfncis.de!not-for-mail |
|---|---|
| From | Joerg Schmitz-Linneweber <joerg@schmitz-linneweber.name> |
| Newsgroups | comp.os.linux.embedded |
| Subject | Re: Reading /proc/stat btime from user space |
| Date | Fri, 18 Jan 2013 16:41:10 +0100 |
| Lines | 33 |
| Message-ID | <alt8qkFcldcU1@mid.dfncis.de> (permalink) |
| References | <2ddadfb4-bd08-4ffa-9153-a009b722eb56@googlegroups.com> <c9e0e710-d63f-40f9-891b-96bcbffcd571@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | news.dfncis.de 91v2PV1jVJ8mOtDVo+LSNw9HJpGgG4PELP3X6s8xnIBpOkdJsA7uKjXJXoJ/C0IHfTkiHO1gVo |
| Cancel-Lock | sha1:daq93xCBO9cmHVuQNXYCRjvYCFM= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20121122 Icedove/10.0.11 |
| In-Reply-To | <c9e0e710-d63f-40f9-891b-96bcbffcd571@googlegroups.com> |
| Xref | csiph.com comp.os.linux.embedded:438 |
Show key headers only | View raw
Hi!
Am 17.01.2013 23:20, schrieb SJC:
> static void get_boottime(char *boottime) {
>
> FILE *fp;
> int status;
>
> fp = popen("awk '/^btime/' /proc/stat", "r");
> if (fp == NULL) {
> DEBUG("get_boottime: popen failed");
> }
> else {
> fgets(boottime, BOOTTIME_MAX_LEN, fp);
> DEBUG("get_boottime: Boottime is %s", boottime);
> status = pclose(fp);
> if (status == -1) {
> DEBUG("get_boottime: Could not close");
> }
> }
> return;
> }
You're kidding, aren't you? :-)
Why not read in the file line-by-line and check if the actual line
starts with 'btime'? (fopen, fgets, strncmp, fclose)
You are starting a new process and creating two pipes to read something
from a (text) file?
Perhaps Tauno's tip was more suitable... ;-)
Salut, Jörg
Back to comp.os.linux.embedded | Previous | Next — Previous in thread | Find similar | Unroll thread
Reading /proc/stat btime from user space SJC <jobhunts02@aol.com> - 2013-01-16 22:37 -0800
Re: Reading /proc/stat btime from user space Joerg Schmitz-Linneweber <joerg@schmitz-linneweber.name> - 2013-01-17 09:12 +0100
Re: Reading /proc/stat btime from user space Joerg Schmitz-Linneweber <joerg@schmitz-linneweber.name> - 2013-01-17 09:17 +0100
Re: Reading /proc/stat btime from user space SJC <jobhunts02@aol.com> - 2013-01-17 10:02 -0800
Re: Reading /proc/stat btime from user space Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2013-01-17 23:10 +0200
Re: Reading /proc/stat btime from user space SJC <jobhunts02@aol.com> - 2013-01-17 14:20 -0800
Re: Reading /proc/stat btime from user space Joerg Schmitz-Linneweber <joerg@schmitz-linneweber.name> - 2013-01-18 16:41 +0100
csiph-web