snice: Fix matching on PID

@MarsChan correctly pointed out that the read() always returns 128
bytes, so skipping on >= 128 will always mean we skip. Their suggestion
was to remove the equality, but read will never go past 128 bytes so
I just removed that part of the check.

References:
 procps-ng/procps!89
This commit is contained in:
Craig Small
2019-10-22 08:14:35 +11:00
parent 52364d548a
commit a2b7106793
2 changed files with 3 additions and 2 deletions

View File

@ -200,9 +200,9 @@ static void check_proc(int pid, struct run_time_conf_t *run_time)
goto closure;
}
len = read(fd, buf, sizeof(buf));
if (len <= 0 || (size_t)len >= sizeof(buf))
if (len <= 0)
goto closure;
buf[len] = '\0';
buf[sizeof(buf) -1] = '\0';
tmp = strrchr(buf, ')');
if (!tmp)
goto closure;