Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.embedded > #438
| From | Joerg Schmitz-Linneweber <joerg@schmitz-linneweber.name> |
|---|---|
| Newsgroups | comp.os.linux.embedded |
| Subject | Re: Reading /proc/stat btime from user space |
| Date | 2013-01-18 16:41 +0100 |
| Message-ID | <alt8qkFcldcU1@mid.dfncis.de> (permalink) |
| References | <2ddadfb4-bd08-4ffa-9153-a009b722eb56@googlegroups.com> <c9e0e710-d63f-40f9-891b-96bcbffcd571@googlegroups.com> |
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