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

1
NEWS
View File

@ -3,6 +3,7 @@ procps-ng-NEXT
* docs: Use correct symbols for -h option in free.1 Debian #898774 * docs: Use correct symbols for -h option in free.1 Debian #898774
* docs: ps.1 now warns about command name length issue #101 * docs: ps.1 now warns about command name length issue #101
* pgrep: Match on runstate issue #109, Debian #919381 * pgrep: Match on runstate issue #109, Debian #919381
* snice: Fix matching on pid merge #89
* top: can now exploit 256-color terminals issue #96 * top: can now exploit 256-color terminals issue #96
* top: preserves 'other filters' in configuration file issue #99 * top: preserves 'other filters' in configuration file issue #99
* top: can now collapse/expand forest view children issue #99 * top: can now collapse/expand forest view children issue #99

View File

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