cgroups freeze 和 golang 中的 linux 命令 "Kill - STOP pid" 有什么区别?

What is the difference between cgroups freeze and linux command "Kill - STOP pid" in golang?

我用这个cgroups包。

我对 type Cgroup 的两个接口感兴趣。一个是Freeze() error,一个是Thaw() error。他们的描述如下:

    ...
    // Freeze freezes or pauses all processes inside the cgroup
    Freeze() error
    // Thaw thaw or resumes all processes inside the cgroup
    Thaw() error
    ...

并且有两个linux命令可以暂停和恢复进程,即kill -STOP pidkill -CONT pid

请问如果一个cgroup中只有一个进程,这两种暂停和恢复进程的方式有什么区别吗?谢谢。

这两个州都是在 10 月引入的。 2016 年 containerd/cgroups commit b3f3344 and refer to cgroup v1 self-state

The cgroup freezer is hierarchical.

Freezing a cgroup freezes all tasks beloning to the cgroup and all its descendant cgroups.
Each cgroup has its own state (self-state) and the state inherited from the parent (parent-state).
Iff both states are THAWED, the cgroup is THAWED.

CGroup Freezer 状态:

freezer.state is only available in non-root cgroups and has three possible values:

  • FROZEN — tasks in the cgroup are suspended.
  • FREEZING — the system is in the process of suspending tasks in the cgroup.
  • THAWED — tasks in the cgroup have resumed.

含义(here):

The freezer subsystem is used to suspend and resume processes in the cgroup.

Freezer has a control file: freezer.state, write FROZEN to this file, you can suspend the process in the cgroup, and write THAWED to this file, you can resume the suspended process.