fix: building with systemd on musl libc systems

This mostly affects postmarketOS as we're the ones pushing musl+systemd
the most currently.
This commit is contained in:
Val Packett
2025-10-30 01:29:52 -03:00
committed by Ivan Molodetskikh
parent 6e8fd15339
commit 4c9df7eb5b
+13
View File
@@ -211,8 +211,21 @@ mod systemd {
use super::*;
pub fn do_spawn(command: &OsStr, mut process: Command) -> Option<Child> {
#[cfg(target_env = "gnu")]
use libc::close_range;
#[cfg(not(target_env = "gnu"))] // musl
pub fn close_range(first: libc::c_uint, last: libc::c_uint, flags: libc::c_uint) -> i64 {
unsafe {
libc::syscall(
libc::SYS_close_range,
first as usize,
last as usize,
flags as usize,
)
}
}
// When running as a systemd session, we want to put children into their own transient
// scopes in order to separate them from the niri process. This is helpful for
// example to prevent the OOM killer from taking down niri together with a