| 393 | } |
| 394 | |
| 395 | func (c *cgroup) processes(subsystem Name, recursive bool, pType procType) ([]Process, error) { |
| 396 | s := c.getSubsystem(subsystem) |
| 397 | sp, err := c.path(subsystem) |
| 398 | if err != nil { |
| 399 | return nil, err |
| 400 | } |
| 401 | if s == nil { |
| 402 | return nil, fmt.Errorf("cgroups: %s doesn't exist in %s subsystem", sp, subsystem) |
| 403 | } |
| 404 | path := s.(pather).Path(sp) |
| 405 | var processes []Process |
| 406 | err = filepath.Walk(path, func(p string, info os.FileInfo, err error) error { |
| 407 | if err != nil { |
| 408 | return err |
| 409 | } |
| 410 | if !recursive && info.IsDir() { |
| 411 | if p == path { |
| 412 | return nil |
| 413 | } |
| 414 | return filepath.SkipDir |
| 415 | } |
| 416 | dir, name := filepath.Split(p) |
| 417 | if name != pType { |
| 418 | return nil |
| 419 | } |
| 420 | procs, err := readPids(dir, subsystem, pType) |
| 421 | if err != nil { |
| 422 | return err |
| 423 | } |
| 424 | processes = append(processes, procs...) |
| 425 | return nil |
| 426 | }) |
| 427 | return processes, err |
| 428 | } |
| 429 | |
| 430 | // Freeze freezes the entire cgroup and all the processes inside it |
| 431 | func (c *cgroup) Freeze() error { |