From 4c9df7eb5b5eadbdb7e42e035147e1c2acb0a7da Mon Sep 17 00:00:00 2001 From: Val Packett Date: Thu, 30 Oct 2025 01:29:52 -0300 Subject: fix: building with systemd on musl libc systems This mostly affects postmarketOS as we're the ones pushing musl+systemd the most currently. --- src/utils/spawning.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/utils/spawning.rs') diff --git a/src/utils/spawning.rs b/src/utils/spawning.rs index 61912eae..ba7564c2 100644 --- a/src/utils/spawning.rs +++ b/src/utils/spawning.rs @@ -211,8 +211,21 @@ mod systemd { use super::*; pub fn do_spawn(command: &OsStr, mut process: Command) -> Option { + #[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 -- cgit