8000 syscall: add PidFD, CgroupFD, and UseCgroupFD options for Linux clone to SysProcAttr · Issue #51246 · golang/go · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
syscall: add PidFD, CgroupFD, and UseCgroupFD options for Linux clone to SysProcAttr #51246
Closed
@kolyshkin

Description

@kolyshkin

Linux 5.3 added a new system call, clone3(), which provides a superset of the functionality of the older clone(). In particular, it adds a way for a child to be spawned in a different cgroup, which solves a number of issues (see CLONE_INTO_CGROUP flag in clone3(2) man page for details).

It would be great for some software written in Go to benefit from this new functionality. Obviously, calling clone3() syscall directly won't work since Go runtime needs to perform specific steps around fork and exec.

So, the support for clone3 needs to be in the syscall package, where clone() is called.

Looks like this can be implemented by amending linux SysProcAttr structure with a pointer to CloneArgs (a new structure that mirrors that of C.clone_args). Then, forkAndExecInChild would use clone3 instead of clone if this pointer is non-nil. This can be used from e.g. os/exec can set cmd.SysProcArgs.CloneArgs.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0