We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 285db17 + 4be65db commit f4ddea3Copy full SHA for f4ddea3
cgroup2/utils.go
@@ -135,16 +135,9 @@ func parseCgroupFile(path string) (string, error) {
135
func parseCgroupFromReader(r io.Reader) (string, error) {
136
s := bufio.NewScanner(r)
137
for s.Scan() {
138
- var (
139
- text = s.Text()
140
- parts = strings.SplitN(text, ":", 3)
141
- )
142
- if len(parts) < 3 {
143
- return "", fmt.Errorf("invalid cgroup entry: %q", text)
144
- }
145
- // text is like "0::/user.slice/user-1001.slice/session-1.scope"
146
- if parts[0] == "0" && parts[1] == "" {
147
- return parts[2], nil
+ // "0::/user.slice/user-1001.slice/session-1.scope"
+ if path, ok := strings.CutPrefix(s.Text(), "0::"); ok {
+ return path, nil
148
}
149
150
if err := s.Err(); err != nil {
0 commit comments