Skip to content

kill_pg could use cgroups if available #435

@pzmarzly

Description

@pzmarzly

Killing a process tree is a hard problem. In dinit, it is currently done via process groups:

void base_process_service::kill_pg(int signo) noexcept
{
if (onstart_flags.signal_process_only) {
bp_sys::kill(pid, signo);
}
else {
pid_t pgid = bp_sys::getpgid(pid);
if (pgid == -1) {
// On some OSes (eg OpenBSD) we aren't allowed to get the pgid of a process in a different
// session. If the process is in a different session, however, it must be a process group
// leader and the pgid must equal the process id.
pgid = pid;
}
bp_sys::kill(-pgid, signo);
}
}

Linux 5.14 added cgroup.kill, which can be used to atomically SIGKILL entire cgroup: https://lwn.net/Articles/855049/

Could dinit also use it, if compiled with cgroup support enabled?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions