Use cgroups.AddProc() for cgroups v1

All occurrences only passed a PID, so we can use this utility to make
the code more symmetrical with their cgroups v2 counterparts.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2021-07-15 10:17:44 +02:00
parent f8585d632a
commit c091d48cb9
4 changed files with 4 additions and 12 deletions

View File

@@ -35,9 +35,7 @@ func setCgroup(cgroupPath string, cmd *exec.Cmd) error {
if err != nil {
return fmt.Errorf("failed to load cgroup %s: %w", cgroupPath, err)
}
if err := cg.Add(cgroups.Process{
Pid: cmd.Process.Pid,
}); err != nil {
if err := cg.AddProc(uint64(cmd.Process.Pid)); err != nil {
return fmt.Errorf("failed to join cgroup %s: %w", cgroupPath, err)
}
return nil