diff options
author | bhackerozzo <bhackerozzo@3b445381-d045-0410-9223-e17ecdb95f4b> | 2008-09-07 16:49:26 +0000 |
---|---|---|
committer | bhackerozzo <bhackerozzo@3b445381-d045-0410-9223-e17ecdb95f4b> | 2008-09-07 16:49:26 +0000 |
commit | c51ccd6f1f9da640b6e2b8624602c713238177ff (patch) | |
tree | fe828cbbc0e2b81df43fa1f3d1cda6ad62488e9b | |
parent | a97e675315e52716f7571f7a3e3ecc9ddea37ff1 (diff) | |
download | cpulimit-c51ccd6f1f9da640b6e2b8624602c713238177ff.tar.gz |
new check_proc()
-rw-r--r-- | cpulimit.c | 25 |
1 files changed, 11 insertions, 14 deletions
@@ -185,20 +185,17 @@ static int get_ncpu() { } #ifdef __linux__ -int check_proc() { - char buffer[1024]; - char dev[32]; - char point[32]; - int found = 0; - FILE *fd = fopen("/etc/mtab", "r"); - while(fgets(buffer, sizeof(buffer), fd) > 0) { - if (strncmp(buffer, "proc ", 5)!=0) continue; - sscanf(buffer, "%s %s", dev, point); - found = 1; - break; - } - fclose(fd); - return found; + +#include <sys/vfs.h> + +static int check_proc() +{ + struct statfs mnt; + if (statfs("/proc", &mnt) < 0) + return 0; + if (mnt.f_type!=0x9fa0) + return 0; + return 1; } #endif |