1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-10-12 19:04:54 +03:00

Fix parsing of /sys/devices/system/cpu/online (bug 25859)

The file contains comma-separated ranges, not spaces.
This commit is contained in:
Andreas Schwab
2020-12-08 19:17:41 +01:00
parent 224b419d1e
commit b5eeca8cfd

View File

@@ -143,6 +143,7 @@ __get_nprocs (void)
char *re = buffer_end;
const int flags = O_RDONLY | O_CLOEXEC;
/* This file contains comma-separated ranges. */
int fd = __open_nocancel ("/sys/devices/system/cpu/online", flags);
char *l;
int result = 0;
@@ -175,10 +176,10 @@ __get_nprocs (void)
result += m - n + 1;
l = endp;
while (l < re && isspace (*l))
if (l < re && *l == ',')
++l;
}
while (l < re);
while (l < re && *l != '\n');
__close_nocancel_nostatus (fd);