aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbhackerozzo <bhackerozzo@3b445381-d045-0410-9223-e17ecdb95f4b>2008-09-07 16:49:26 +0000
committerbhackerozzo <bhackerozzo@3b445381-d045-0410-9223-e17ecdb95f4b>2008-09-07 16:49:26 +0000
commitc51ccd6f1f9da640b6e2b8624602c713238177ff (patch)
treefe828cbbc0e2b81df43fa1f3d1cda6ad62488e9b
parenta97e675315e52716f7571f7a3e3ecc9ddea37ff1 (diff)
downloadcpulimit-c51ccd6f1f9da640b6e2b8624602c713238177ff.tar.gz
new check_proc()
-rw-r--r--cpulimit.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/cpulimit.c b/cpulimit.c
index 10dd1ab..f89b11b 100644
--- a/cpulimit.c
+++ b/cpulimit.c
@@ -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
Un proyecto texto-plano.xyz