Skip to content

Conversation

@vaxerski
Copy link
Member

@vaxerski vaxerski commented Dec 7, 2025

This won't work on BSD in the current state. @tagattie, can we get PPid + name of any PID on BSDs?

In the future, I'd prefer to use a cgroup within Hyprland, then use that in shutdown, but IIRC BSD doesn't have that. What's the situation look like over there?

@tagattie
Copy link

tagattie commented Dec 8, 2025

Hi @vaxerski,

This won't work on BSD in the current state. @tagattie, can we get PPid + name of any PID on BSDs?

FreeBSD has sysctl(3) function which can be used for this purpose. Using the function, we can list all processes and search for ones whose parent is Hyprland.

In the future, I'd prefer to use a cgroup within Hyprland, then use that in shutdown, but IIRC BSD doesn't have that. What's the situation look like over there?

I'm not very familiar with cgroup. Is that a mechanism for limiting resources usable by a process? If so, FreeBSD has a command rctl for limitng CPU and memory resources for a process.

@vaxerski
Copy link
Member Author

vaxerski commented Dec 8, 2025

cgroups can limit resources but here we'd use them to group processes. Once Hyprland would make a cgroup (let's say hyprland-1) then all spawned children would belong under hyprland-1, giving us a way to track descendants even if they double-fork.

@tagattie
Copy link

tagattie commented Dec 9, 2025

As far as I know, BSDs don't have a similar mechanism. So BSDs would have to list up all processes and check one by one if one's parent (or grandparent, ...) is Hyprland.

@vaxerski
Copy link
Member Author

vaxerski commented Dec 9, 2025

does it persist through double-forks? Thats the problem on linux at least, if a process forks twice and the first fork exits, PPid is set to 1.

@tagattie
Copy link

I'm afraid not. PPid is set to 1 too on BSDs.

I did some research on this topic about BSDs. I have found FreeBSD has procctl(2) which enables a "reaper" process can manage life/death of all its decendants regardless of their generations (child, grandchild, ...) even when mid-level process is killed. However, it is a FreeBSD-specific feature and no other BSDs have similar function.

So generally speaking BSDs provide no reliable mechanism for PPid tracking in that scenario.

@vaxerski
Copy link
Member Author

hey @tagattie I've added BSD code for name, ppid and listing processes. This could use a review / test, as I can't verify the code working on any BSD. Also please check the mibs if you can because I know jbeich added that #if defined(__NetBSD__) || defined(__OpenBSD__) to ppid (that's copied from hyprland) but I did not add it to getting all pids, as the online example didnt have it. Is it required?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants