cgroup_get_from_path(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… cgroup_get_from_path(9) β€” from the Kernel API Manual, bestie

Okay so this one's a kernel API page, and yes it's short, but it's lowkey iconic. It's literally called cgroup_get_from_path and it's about grabbing a cgroup by its path. We move. πŸ¦‹


✨ NAME ✨

cgroup_get_from_path β€” look up a cgroup by its path on the default hierarchy and get a reference to it. That's the whole vibe.


🌸 SYNOPSIS 🌸

struct cgroup * cgroup_get_from_path (const char *path );

πŸŽ€ ARGUMENTS πŸŽ€

  • path β€” the path on the default hierarchy. That's it. That's the whole argument. She's simple, she's elegant. πŸ‘‘

πŸ’– DESCRIPTION πŸ’–

So what happens is: it finds the cgroup at path on the default hierarchy, increments its reference count, and returns it. Like, it gets it β€” hence the name, no cap. 🫢

On success you get a pointer to the found cgroup. Slay.

But if things go sideways, you get one of these instead:

  • ERR_PTR(-ENOENT) β€” returned if path doesn't exist, or if the cgroup has already been released. Yeah, those are two different situations sharing one error code, and yes that's a little chaotic of them, but that's what the page says. 😭
  • ERR_PTR(-ENOTDIR) β€” returned if path points to something that is not a directory. Respectfully, not a directory, not our problem. πŸ’€
ngl, check your path before you call this. The kernel will absolutely tell you what's wrong via those error pointers, but it will not be gentle about it.

🌈 SEE ALSO 🌈

Kernel file ./kernel/cgroup/cgroup.c, plus the whole extended friend group of cgroup and css functions β€” go read these next, iykyk:

Like, that's a lot of reading. Bring snacks. πŸ“


Okay bye bestie, go increment some reference counts and remember to actually put them back πŸ’œ β€” this page lives under ./kernel/cgroup in the Kernel API Manual, dated October 2026. Periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from