linux: Support 4.10 format for empty Groups: lines in /proc/pid/status

The Groups: line unfortunately always had a trailing space, but Linux
4.10 takes this to a new level by including a trailing space even when
no groups are present. See commit f7a5f132b447,
linux-4.10.10/fs/proc/array.c task_state().

Bug: crashpad:30
Test: crashpad_util_test ProcessInfo.Pid1
Change-Id: If498abd929b27c7f28b69144e7c4928b1626acdb
Reviewed-on: https://chromium-review.googlesource.com/477070
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
Mark Mentovai 2017-04-13 12:48:25 -04:00
parent 5d07d81458
commit 2ec34e32c2

View File

@ -209,6 +209,8 @@ bool ProcessInfo::Initialize(pid_t pid) {
LOG(ERROR) << "format error: multiple Groups lines"; LOG(ERROR) << "format error: multiple Groups lines";
return false; return false;
} }
if (!AdvancePastPrefix(&line_c, " ")) {
// In Linux 4.10, even an empty Groups: line has a trailing space.
gid_t group; gid_t group;
while (AdvancePastNumber(&line_c, &group)) { while (AdvancePastNumber(&line_c, &group)) {
supplementary_groups_.insert(group); supplementary_groups_.insert(group);
@ -217,6 +219,7 @@ bool ProcessInfo::Initialize(pid_t pid) {
return false; return false;
} }
} }
}
have_groups = true; have_groups = true;
understood_line = true; understood_line = true;
} }