diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index b725a17761..e010fc7b5a 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -985,10 +985,9 @@ int cg_get_xattr(const char *controller, const char *path, const char *name, voi int cg_pid_get_path(const char *controller, pid_t pid, char **path) { _cleanup_fclose_ FILE *f = NULL; - char line[LINE_MAX]; const char *fs, *controller_str; + int unified, r; size_t cs = 0; - int unified; assert(path); assert(pid >= 0); @@ -1018,10 +1017,15 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **path) { (void) __fsetlocking(f, FSETLOCKING_BYCALLER); - FOREACH_LINE(line, f, return -errno) { + for (;;) { + _cleanup_free_ char *line = NULL; char *e, *p; - truncate_nl(line); + r = read_line(f, LONG_LINE_MAX, &line); + if (r < 0) + return r; + if (r == 0) + break; if (unified) { e = startswith(line, "0:");