cgroups.7: Clarify discussion of the "tasks" file

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2016-10-07 13:10:31 +02:00
parent 9ed582ac20
commit 87402a2e5b
1 changed files with 17 additions and 5 deletions

View File

@ -222,20 +222,32 @@ A new cgroup is created by creating a directory in the cgroup filesystem:
mkdir /sys/fs/cgroup/cpu/cg1
This creates a new empty cgroup.
Processes (threads) may be moved to this cgroup by writing
their PIDs (TIDs) into the cgroup's
Processes may be moved to this cgroup by writing
their PIDs into the cgroup's
.I cgroup.procs
.RI ( tasks )
file:
echo $$ > /sys/fs/cgroup/cpu/cg1/cgroup.procs
The same files can be read to obtain a list of the processes (threads)
The same file can be read to obtain a list of the processes
that are currently in
.IR cg1 .
When writing a PID into the
.IR cgroup.procs ,
all tasks in the process are moved into the new cgroup at once.
all threads in the process are moved into the new cgroup at once.
In cgroups v1 (but not cgroups v2), an individual thread can be moved to
another cgroup by writing its thread ID
(i.e., the kernel thread ID returned by
.BR clone (2)
and
.BR gettid (2))
to the
.IR tasks
file in a cgroup directory.
This file can be read to discover the set of threads
that are members of the cgroup.
This file is not present in cgroup v2 directories.
A child process created via
.BR fork (2)