Skip to content

Commit ebb404e

Browse files
committed
Docs: Add section on setting/getting cgroup2 type
Follow up to #270; forgot to add a bit in the README. Signed-off-by: Danny Canter <danny@dcantah.dev>
1 parent eeed8ff commit ebb404e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,27 @@ if err != nil {
201201
}
202202
```
203203

204+
205+
### Get and set cgroup type
206+
```go
207+
m, err := cgroup2.LoadSystemd("/", "my-cgroup-abc.slice")
208+
if err != nil {
209+
return err
210+
}
211+
212+
// https://www.kernel.org/doc/html/v5.0/admin-guide/cgroup-v2.html#threads
213+
cgType, err := m.GetType()
214+
if err != nil {
215+
return err
216+
}
217+
fmt.Println(cgType)
218+
219+
err = m.SetType(cgroup2.Threaded)
220+
if err != nil {
221+
return err
222+
}
223+
```
224+
204225
### Attention
205226

206227
All static path should not include `/sys/fs/cgroup/` prefix, it should start with your own cgroups name

0 commit comments

Comments
 (0)