join_cgroup(9)
π join_cgroup(9) π
okay so this is a page from the Kernel API Manual bestie, and we're talking about join_cgroup β yes the actual function, the one that puts your process into a cgroup. sit down, hydrate, let's go π«Ά
β¨ NAME β¨
join_cgroup β join a cgroup. that's it. that's the whole vibe. you show up, you join. π
πΈ SYNOPSIS πΈ
int join_cgroup (const char *relative_path );
likeβ¦ it takes one thing and returns an int. she's lowkey simple and we love her for it. β¨
π ARGUMENTS π
relative_pathβ the cgroup path you wanna join, but relative to the workdir, not absolute. so don't come at her with a full path, she will not be doing that. π
π¦ DESCRIPTION π¦
okay so real talk: this function expects the cgroup to already exist, created relative to the cgroup work dir, and then it justβ¦ joins it. no creation, no setup, no nothing. the cgroup is already there, you're just moving in. π β¨
and the example is genuinely so iconic β if you pass "/my-cgroup" as the path, it doesn't put you in /my-cgroup (sorry bestie), it actually puts the calling process into the cgroup "/cgroup-test-work-dir/my-cgroup". the work dir is doing all the heavy lifting. main character energy fr fr π
on success, it returns 0. otherwise, on failure, it returns 1. that's the whole exit situation β binary, no in-between, no crumbs. π
π₯ SEE ALSO π₯
first up, the actual source of truth, the kernel file to go read with your own eyeballs:
./tools/testing/selftests/bpf/cgroup_helpers.c
and then the whole friend group, because this function does not exist in a vacuum, she has a whole support system:
enable_controllers(9)write_cgroup_file(9)write_cgroup_file_parent(9)setup_cgroup_environment(9)join_root_cgroup(9)join_parent_cgroup(9)set_cgroup_xattr(9)__cleanup_cgroup_environment(9)cleanup_cgroup_environment(9)get_root_cgroup(9)create_and_get_cgroup(9)get_cgroup_id_from_path(9)setup_classid_environment(9)set_classid(9)join_classid(9)cleanup_classid_environment(9)get_classid_cgroup_id(9)get_cgroup1_hierarchy_id(9)open_classid(9)
like, go read those too, they're all part of the same selftest saga π§ββοΈ
β οΈ tiny reminder bestie: this one joins, it does not create. if the cgroup isn't already there relative to the work dir, that's on you, and you'll be getting that 1 back. not me being the one to tell you, butβ¦ π
and that's the page!! π this whole thing lives in ./tools/testing/selftests/bpf, and it's dated October 2026 β so yes, she's from the future, she's ahead of her time, we stan a time-traveling manual page βπ bye bestie, go join a cgroup responsibly π¦
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms