join_cgroup(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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:

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