Mercurial > crates > systemd-socket
view tests/ordinary.rs @ 25:8e20daee41ed
Set CLOEXEC flag on the descriptors
The received systemd descriptors don't have `O_CLOEXEC` set because they
are received over `exec`. Thus if the process executes a child the child
gets polluted with the descriptors.
To prevent this, we set `O_CLOEXEC` during initialization. However this
also required restructuring of the code because `libsystemd` doesn't
provide temporary access to the descriptors - only permanent one. Thus
we have to "validate" the descriptors eagerly. We still store the
invalid ones as errors to make sure the errors get reported accurately.
author | Martin Habovstiak <martin.habovstiak@gmail.com> |
---|---|
date | Fri, 28 Feb 2025 21:11:19 +0100 |
parents | 66c0e10c89fc |
children | cfef4593e207 |
line wrap: on
line source
use std::io; use std::ffi::OsStr; use std::process::{Command, Child}; mod comm; enum Test {} impl comm::Test for Test { const SOCKET_ADDR: &'static str = "localhost:4242"; fn spawn_slave(program_name: &OsStr) -> io::Result<Child> { Command::new(program_name) .env("SYSTEMD_SOCKET_INTEGRATION_TEST", "slave") .spawn() } } #[test] fn main() { comm::main::<Test>(); }