diff --git a/libcontainer/cgroups/systemd/v1.go b/libcontainer/cgroups/systemd/v1.go index a805f72c..5d324133 100644 --- a/libcontainer/cgroups/systemd/v1.go +++ b/libcontainer/cgroups/systemd/v1.go @@ -125,7 +125,7 @@ func genV1ResourcesProperties(c *configs.Cgroup) ([]systemdDbus.Property, error) newProp("BlockIOWeight", uint64(c.Resources.BlkioWeight))) } - if c.Resources.PidsLimit > 0 { + if c.Resources.PidsLimit > 0 || c.Resources.PidsLimit == -1 { properties = append(properties, newProp("TasksAccounting", true), newProp("TasksMax", uint64(c.Resources.PidsLimit))) diff --git a/libcontainer/cgroups/systemd/v2.go b/libcontainer/cgroups/systemd/v2.go index b929e880..2fcf312a 100644 --- a/libcontainer/cgroups/systemd/v2.go +++ b/libcontainer/cgroups/systemd/v2.go @@ -92,7 +92,7 @@ func genV2ResourcesProperties(c *configs.Cgroup) ([]systemdDbus.Property, error) newProp("CPUQuotaPerSecUSec", cpuQuotaPerSecUSec)) } - if c.Resources.PidsLimit > 0 { + if c.Resources.PidsLimit > 0 || c.Resources.PidsLimit == -1 { properties = append(properties, newProp("TasksAccounting", true), newProp("TasksMax", uint64(c.Resources.PidsLimit))) diff --git a/tests/integration/update.bats b/tests/integration/update.bats index ca47f850..76d931f5 100644 --- a/tests/integration/update.bats +++ b/tests/integration/update.bats @@ -161,6 +161,12 @@ EOF check_cgroup_value "pids.max" 10 check_systemd_value "TasksMax" 10 + # unlimited + runc update test_update --pids-limit -1 + [ "$status" -eq 0 ] + check_cgroup_value "pids.max" max + check_systemd_value "TasksMax" $SD_UNLIMITED + # Revert to the test initial value via json on stdin runc update -r - test_update <