aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbhackerozzo <bhackerozzo@3b445381-d045-0410-9223-e17ecdb95f4b>2010-04-23 21:42:51 +0000
committerbhackerozzo <bhackerozzo@3b445381-d045-0410-9223-e17ecdb95f4b>2010-04-23 21:42:51 +0000
commit868cf1efc39b039f3d73201be5031bf693f9c8fd (patch)
treebe2202ce20cd56a99a022b1a62eafbbf6be30c30
parentb3160c7529c895cddd98493a812b555a6c9d6c8e (diff)
downloadcpulimit-868cf1efc39b039f3d73201be5031bf693f9c8fd.tar.gz
fixed fgets() call - tnx erik
-rw-r--r--process.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/process.c b/process.c
index 6054a63..b2f8e6f 100644
--- a/process.c
+++ b/process.c
@@ -104,7 +104,7 @@ static int get_starttime(pid_t pid)
sprintf(file, "/proc/%d/stat", pid);
FILE *fd = fopen(file, "r");
if (fd==NULL) return -1;
- if (fgets(buffer, sizeof(buffer), fd)==NULL) return -1;
+ if (fgets(buffer, sizeof(buffer), fd) == NULL) return -1;
fclose(fd);
char *p = buffer;
p = memchr(p+1,')', sizeof(buffer) - (p-buffer));
@@ -125,7 +125,7 @@ static int get_jiffies(struct process *proc) {
#ifdef __linux__
FILE *f = fopen(proc->stat_file, "r");
if (f==NULL) return -1;
- if (fgets(proc->buffer, sizeof(proc->buffer),f)) return -1;
+ if (fgets(proc->buffer, sizeof(proc->buffer),f) == NULL) return -1;
fclose(f);
char *p = proc->buffer;
p = memchr(p+1,')', sizeof(proc->buffer) - (p-proc->buffer));
Un proyecto texto-plano.xyz