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