Building with systemd on musl libc systems
Browse files at this commit4c9df7eb5b5eadbdb7e42e035147e1c2acb0a7daParent: 6e8fd15- fix
- building with systemd on musl libc systems
1 changed file +13 -0
- src/utils/spawning.rs +13 -0
src/utils/spawning.rsmodified+13 -0
| @@ -211,8 +211,21 @@ mod systemd { | |||
| 211 | use super::*; | 211 | use super::*; |
| 212 | 212 | ||
| 213 | pub fn do_spawn(command: &OsStr, mut process: Command) -> Option<Child> { | 213 | pub fn do_spawn(command: &OsStr, mut process: Command) -> Option<Child> { |
| 214 | + #[cfg(target_env = "gnu")] | ||
| 214 | use libc::close_range; | 215 | use libc::close_range; |
| 215 | 216 | ||
| 217 | + #[cfg(not(target_env = "gnu"))] // musl | ||
| 218 | + pub fn close_range(first: libc::c_uint, last: libc::c_uint, flags: libc::c_uint) -> i64 { | ||
| 219 | + unsafe { | ||
| 220 | + libc::syscall( | ||
| 221 | + libc::SYS_close_range, | ||
| 222 | + first as usize, | ||
| 223 | + last as usize, | ||
| 224 | + flags as usize, | ||
| 225 | + ) | ||
| 226 | + } | ||
| 227 | + } | ||
| 228 | + | ||
| 216 | // When running as a systemd session, we want to put children into their own transient | 229 | // When running as a systemd session, we want to put children into their own transient |
| 217 | // scopes in order to separate them from the niri process. This is helpful for | 230 | // scopes in order to separate them from the niri process. This is helpful for |
| 218 | // example to prevent the OOM killer from taking down niri together with a | 231 | // example to prevent the OOM killer from taking down niri together with a |