subc_os/lib.rs
1//! Operating-system primitives the subc daemon needs and cannot reach without
2//! unsafe code, each behind a small safe API.
3//!
4//! The daemon crates forbid unsafe code. This crate is the one deliberate
5//! exception (like `subc-uptime` and `subc-cgroup`): every `unsafe` block here
6//! is a single foreign call with its preconditions stated beside it, and nothing
7//! unsafe is exported.
8//!
9//! Today it answers one question: is the process now holding pid N the same
10//! process the daemon spawned earlier? A pid alone cannot say, because the
11//! kernel reuses pids once a process has been reaped. [`Process`] reads the two
12//! facts that tell processes apart, the kernel's start time for the pid and the
13//! file identity (device and inode) of the executable image it runs, and sends
14//! signals to it.
15//!
16//! Sources, per platform:
17//!
18//! - Linux: the start time is field 22 of `/proc/<pid>/stat` (clock ticks since
19//! boot), and the executable is `stat` through `/proc/<pid>/exe`, which
20//! resolves to the running image even if its file has since been replaced or
21//! deleted. A pidfd is opened before either is read and signals go through it
22//! (`pidfd_send_signal`), so the process that was checked is the process that
23//! is signalled. No unsafe code is needed: rustix wraps both calls.
24//! - macOS: the start time is `kp_proc.p_starttime` from `sysctl`
25//! `KERN_PROC_PID` (microseconds since the epoch), and the executable is the
26//! path `proc_pidpath` reports, then `stat` on that path. These two calls are
27//! unsafe. macOS has no pidfd, so a signal is a plain
28//! `kill` sent right after the checks; see [`Process::signal`].
29//! - Windows: creation time and forced stops use one retained process handle.
30//! `ExecutableCapture` pins the resolved executable until a suspended spawn
31//! binds its volume and 128-bit file ID to that handle and creation time.
32//! - Anywhere else: [`Process::open`] reports [`std::io::ErrorKind::Unsupported`].
33//!
34//! For persisted PID owners, [`process_identity`] reads versioned kernel start
35//! identities and distinguishes alive, dead and unknown without spawning a
36//! process. Its foreign calls are signal-zero `kill` on Unix and `proc_pidinfo`
37//! on macOS. Only dead owners may be reclaimed; unknown owners stay protected.
38//!
39//! It also reads how much memory and CPU time one process is using, for
40//! reporting only; see [`resource_usage`]. On Linux that is procfs again; on
41//! macOS it is `proc_pid_rusage`, plus `mach_timebase_info` to convert its CPU
42//! times to nanoseconds, the other two unsafe calls in the crate.
43//!
44//! And it carries the launch nonce from the daemon to each module it spawns
45//! over an inherited pipe instead of the environment: [`launch_nonce`] is the
46//! one reader every module uses, and [`LaunchNonceHandoff`] the daemon's half.
47//! That module's unsafe code is `dup2`, `fcntl`, `fstat` and `ioctl` on
48//! descriptors, each with its preconditions stated beside it.
49
50#![deny(unsafe_code)]
51
52#[cfg(all(unix, feature = "test-support"))]
53pub mod fork_exec_test;
54pub mod launch_nonce;
55pub mod privacy_identity;
56pub mod process_identity;
57#[cfg(windows)]
58pub mod windows_acl;
59#[cfg(unix)]
60pub use launch_nonce::LaunchNonceHandoff;
61pub use launch_nonce::{
62 launch_nonce, LaunchNonce, LaunchNonceError, LaunchNonceSource, LAUNCH_NONCE_ENV,
63 LAUNCH_NONCE_FD, LAUNCH_NONCE_FD_ENV,
64};
65
66#[cfg(target_os = "linux")]
67mod linux;
68#[cfg(target_os = "macos")]
69mod macos;
70#[cfg(windows)]
71mod windows;
72#[cfg(all(test, windows))]
73mod windows_tests;
74#[cfg(windows)]
75pub use windows::{
76 ExecutableCapture, ImageAgreement, ImageUnavailable, SpawnedImage, WindowsFileIdentity,
77};
78
79#[cfg(target_os = "linux")]
80use linux as platform;
81#[cfg(target_os = "macos")]
82use macos as platform;
83
84use std::{io, path::Path};
85
86/// True where [`Process`] can identify and stop a process by pid.
87pub const PROCESS_IDENTITY_SUPPORTED: bool =
88 cfg!(any(target_os = "linux", target_os = "macos", windows));
89
90/// Device and inode of a file: which file, independent of the name used to
91/// reach it.
92#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
93pub struct FileIdentity {
94 pub device: u64,
95 pub inode: u64,
96}
97
98/// The device and inode of the file at `path`, following symlinks. `None` if it
99/// cannot be read or the platform has no inode numbers.
100pub fn file_identity(path: &Path) -> Option<FileIdentity> {
101 #[cfg(unix)]
102 {
103 use std::os::unix::fs::MetadataExt;
104
105 std::fs::metadata(path).ok().map(|metadata| FileIdentity {
106 device: metadata.dev(),
107 inode: metadata.ino(),
108 })
109 }
110 #[cfg(not(unix))]
111 {
112 let _ = path;
113 None
114 }
115}
116
117/// What a live process looks like right now.
118#[derive(Debug, Clone, Copy, PartialEq, Eq)]
119pub struct Observation {
120 /// The kernel's start time for the process. Opaque: compare it only with a
121 /// value read on the same host by this crate. Linux counts clock ticks since
122 /// boot; macOS counts microseconds since the epoch; Windows counts 100 ns
123 /// intervals since the Windows epoch.
124 pub start_time: u64,
125 /// The file the process is executing, or `None` if it could not be read
126 /// (for example, a process owned by another user).
127 /// Windows uses the full file ID in `SpawnedImage` instead of a Unix inode;
128 /// this field is always `None` there.
129 pub executable: Option<FileIdentity>,
130}
131
132/// A signal [`Process::signal`] can send.
133#[derive(Debug, Clone, Copy, PartialEq, Eq)]
134pub enum Signal {
135 /// SIGTERM: a request to exit, which the process may handle or ignore.
136 Terminate,
137 /// SIGKILL: ends the process; it cannot be handled or ignored.
138 Kill,
139}
140
141/// The kernel start time of the process holding `pid`, or `None` if there is
142/// none, it has already exited (a zombie waiting to be reaped counts as exited),
143/// or the platform has no source.
144pub fn start_time(pid: u32) -> Option<u64> {
145 #[cfg(any(target_os = "linux", target_os = "macos"))]
146 {
147 platform::start_time(pid)
148 }
149 #[cfg(windows)]
150 {
151 Process::open(pid)
152 .ok()??
153 .observe()
154 .map(|observation| observation.start_time)
155 }
156 #[cfg(not(any(target_os = "linux", target_os = "macos", windows)))]
157 {
158 let _ = pid;
159 None
160 }
161}
162
163/// True where [`resource_usage`] can read a live process. Elsewhere it always
164/// answers `None`, and a caller can use this to say "not supported here"
165/// rather than "could not read".
166pub const RESOURCE_USAGE_SUPPORTED: bool =
167 cfg!(any(target_os = "linux", target_os = "macos", windows));
168
169/// What [`ResourceUsage::memory_bytes`] measures. The platforms offer
170/// different figures, and they are not interchangeable.
171#[derive(Debug, Clone, Copy, PartialEq, Eq)]
172pub enum MemoryKind {
173 /// macOS `phys_footprint`: the memory the kernel charges to the process
174 /// (dirty and compressed pages, among others), which is also what jetsam
175 /// acts on. Pages an allocator has released with `MADV_FREE` do not count.
176 PhysFootprint,
177 /// Linux `VmRSS`: pages of the process resident in RAM, including shared
178 /// file-backed pages. Swapped-out pages are not included; see
179 /// [`ResourceUsage::swap_bytes`].
180 ResidentSet,
181 /// Windows `WorkingSetSize`: pageable memory currently resident in RAM,
182 /// including shared pages. This is not Unix RSS or private committed memory.
183 WindowsWorkingSet,
184}
185
186/// One reading of a process's memory and cumulative CPU time.
187///
188/// It covers the process named by the pid alone: its threads are included,
189/// processes it has started are not.
190#[derive(Debug, Clone, Copy, PartialEq, Eq)]
191pub struct ResourceUsage {
192 /// Memory in bytes, measured as [`Self::memory_kind`] says.
193 pub memory_bytes: u64,
194 pub memory_kind: MemoryKind,
195 /// Bytes swapped out (Linux `VmSwap`). `None` where the platform does not
196 /// report it for a single process, which is not the same as zero.
197 pub swap_bytes: Option<u64>,
198 /// CPU time spent in user mode since the process started.
199 pub cpu_user: std::time::Duration,
200 /// CPU time spent in the kernel on the process's behalf since it started.
201 pub cpu_system: std::time::Duration,
202}
203
204/// Memory and cumulative CPU time of the process holding `pid`, read now.
205///
206/// `None` when there is no such process, it has exited (a zombie awaiting its
207/// reap counts as exited), it cannot be read (for example, another user's
208/// process on macOS), or the platform has no source
209/// (see [`RESOURCE_USAGE_SUPPORTED`]). Never a reading of zeros in place of
210/// one of those.
211///
212/// Like any pid-based read, this describes whatever process holds `pid` now;
213/// a caller that needs it to be a particular process should confirm that
214/// process's [`start_time`] around the call.
215pub fn resource_usage(pid: u32) -> Option<ResourceUsage> {
216 #[cfg(any(target_os = "linux", target_os = "macos"))]
217 {
218 platform::resource_usage(pid)
219 }
220 #[cfg(windows)]
221 {
222 Process::open(pid).ok()??.resource_usage()
223 }
224 #[cfg(not(any(target_os = "linux", target_os = "macos", windows)))]
225 {
226 let _ = pid;
227 None
228 }
229}
230
231/// A handle on the process holding one pid at the moment it was opened.
232#[derive(Debug)]
233pub struct Process {
234 pid: u32,
235 #[cfg(target_os = "linux")]
236 pidfd: Option<std::os::fd::OwnedFd>,
237 #[cfg(windows)]
238 handle: std::os::windows::io::OwnedHandle,
239}
240
241impl Process {
242 /// Open a handle on the process now holding `pid`.
243 ///
244 /// `Ok(None)` means no process holds that pid (on macOS, also a zombie
245 /// awaiting its reap; on Linux a zombie opens, and [`Self::observe`] then
246 /// reports it as exited). On Linux this opens a pidfd,
247 /// which from then on refers to this exact process even if it exits and the
248 /// pid is reused; when the kernel cannot open one (older than 5.3, or a
249 /// seccomp policy refusing the call) the handle falls back to the pid, as
250 /// on macOS.
251 pub fn open(pid: u32) -> io::Result<Option<Self>> {
252 #[cfg(target_os = "linux")]
253 {
254 linux::open(pid).map(|opened| opened.map(|pidfd| Self { pid, pidfd }))
255 }
256 #[cfg(target_os = "macos")]
257 {
258 Ok(platform::exists(pid).then_some(Self { pid }))
259 }
260 #[cfg(windows)]
261 {
262 windows::open(pid).map(|opened| opened.map(|handle| Self { pid, handle }))
263 }
264 #[cfg(not(any(target_os = "linux", target_os = "macos", windows)))]
265 {
266 let _ = pid;
267 Err(io::Error::new(
268 io::ErrorKind::Unsupported,
269 "process identity is not available on this platform",
270 ))
271 }
272 }
273
274 pub fn pid(&self) -> u32 {
275 self.pid
276 }
277
278 /// True when signals go through a pidfd, so they cannot reach a different
279 /// process that has since reused this pid.
280 pub fn signals_through_pidfd(&self) -> bool {
281 #[cfg(target_os = "linux")]
282 {
283 self.pidfd.is_some()
284 }
285 #[cfg(not(target_os = "linux"))]
286 {
287 false
288 }
289 }
290
291 /// The process's start time and executable, or `None` once it has exited
292 /// (including as a zombie not yet reaped by its parent).
293 pub fn observe(&self) -> Option<Observation> {
294 #[cfg(any(target_os = "linux", target_os = "macos"))]
295 {
296 #[cfg(target_os = "linux")]
297 if !linux::pidfd_alive(self.pidfd.as_ref()) {
298 return None;
299 }
300 let start_time = platform::start_time(self.pid)?;
301 Some(Observation {
302 start_time,
303 executable: platform::executable_identity(self.pid),
304 })
305 }
306 #[cfg(windows)]
307 {
308 windows::observe(self)
309 }
310 #[cfg(not(any(target_os = "linux", target_os = "macos", windows)))]
311 {
312 None
313 }
314 }
315
316 /// Wait on the retained Windows handle. `Ok(false)` means the bound elapsed,
317 /// not that a reused PID was observed.
318 #[cfg(windows)]
319 pub fn wait_for_exit(&self, timeout: std::time::Duration) -> io::Result<bool> {
320 windows::wait(self, timeout)
321 }
322
323 /// Force the confirmed Windows process to stop, then wait on the same handle.
324 /// This is not a graceful termination signal. A different creation time
325 /// refuses before any action; `Ok(false)` means the wait bound elapsed.
326 #[cfg(windows)]
327 pub fn force_stop(
328 &self,
329 expected_start_time: u64,
330 timeout: std::time::Duration,
331 ) -> io::Result<bool> {
332 windows::force_stop(self, expected_start_time, timeout)
333 }
334
335 /// Windows resources read through the retained handle, not by reopening its PID.
336 #[cfg(windows)]
337 pub fn resource_usage(&self) -> Option<ResourceUsage> {
338 windows::resource_usage(self)
339 }
340
341 /// Send `signal` to the process.
342 ///
343 /// With a pidfd the signal can only reach the process this handle was
344 /// opened on: if that process has exited, the call fails with `ESRCH` even
345 /// if the pid has been reused. Without one (macOS, or a Linux kernel with no
346 /// pidfd) the signal goes to whatever holds the pid now, so callers should
347 /// [`Self::observe`] immediately before signalling. What remains is the
348 /// time between that check and this call; for a different process to be
349 /// hit, the checked one must exit, be reaped, and have its pid handed to a
350 /// new process inside that window, and both kernels hand out pids in
351 /// increasing order, so a reuse needs the whole pid space to wrap first.
352 ///
353 /// `Ok(false)` means the process had already exited (`ESRCH`).
354 pub fn signal(&self, signal: Signal) -> io::Result<bool> {
355 #[cfg(any(target_os = "linux", target_os = "macos"))]
356 {
357 #[cfg(target_os = "linux")]
358 let result = linux::signal(self.pid, self.pidfd.as_ref(), signal);
359 #[cfg(target_os = "macos")]
360 let result = macos::signal(self.pid, signal);
361 match result {
362 Ok(()) => Ok(true),
363 Err(rustix::io::Errno::SRCH) => Ok(false),
364 Err(error) => Err(error.into()),
365 }
366 }
367 #[cfg(not(any(target_os = "linux", target_os = "macos")))]
368 {
369 let _ = signal;
370 Err(io::Error::new(
371 io::ErrorKind::Unsupported,
372 "process signalling is not available on this platform",
373 ))
374 }
375 }
376}
377
378#[cfg(all(test, any(target_os = "linux", target_os = "macos")))]
379mod tests {
380 use std::{
381 process::{Child, Command},
382 time::{Duration, Instant},
383 };
384
385 use super::*;
386
387 fn spawn_sleep() -> Child {
388 Command::new("sleep")
389 .arg("60")
390 .spawn()
391 .expect("spawn sleep")
392 }
393
394 /// The executable a spawned `sleep` runs, resolved the way `Command` found it.
395 fn sleep_identity() -> FileIdentity {
396 let path = ["/bin/sleep", "/usr/bin/sleep"]
397 .into_iter()
398 .find(|path| Path::new(path).exists())
399 .expect("sleep is installed");
400 file_identity(Path::new(path)).expect("stat sleep")
401 }
402
403 /// Right after `spawn` returns the child may not have finished exec yet,
404 /// and until then it still runs the test binary's image.
405 fn wait_for_executable(process: &Process, expected: FileIdentity) -> Observation {
406 let deadline = Instant::now() + Duration::from_secs(5);
407 loop {
408 let observation = process.observe().expect("child is alive");
409 if observation.executable == Some(expected) || Instant::now() > deadline {
410 return observation;
411 }
412 std::thread::sleep(Duration::from_millis(10));
413 }
414 }
415
416 #[test]
417 fn own_process_is_observable_with_its_own_image() {
418 let process = Process::open(std::process::id())
419 .expect("open own process")
420 .expect("own process exists");
421 let observation = process.observe().expect("own process is alive");
422 let own_image = file_identity(&std::env::current_exe().unwrap()).unwrap();
423 assert_eq!(observation.executable, Some(own_image));
424 assert_eq!(start_time(std::process::id()), Some(observation.start_time));
425 }
426
427 #[test]
428 fn child_start_time_is_stable_and_differs_from_ours() {
429 let mut child = spawn_sleep();
430 let pid = child.id();
431 let process = Process::open(pid).unwrap().unwrap();
432 let observation = wait_for_executable(&process, sleep_identity());
433 assert_eq!(observation.executable, Some(sleep_identity()));
434 assert_eq!(start_time(pid), Some(observation.start_time));
435 child.kill().unwrap();
436 child.wait().unwrap();
437 }
438
439 #[test]
440 fn a_signalled_and_unreaped_child_reads_as_exited() {
441 let mut child = spawn_sleep();
442 let process = Process::open(child.id()).unwrap().unwrap();
443 assert!(process.signal(Signal::Terminate).unwrap());
444 let deadline = Instant::now() + Duration::from_secs(5);
445 while process.observe().is_some() {
446 assert!(Instant::now() < deadline, "child still observed as alive");
447 std::thread::sleep(Duration::from_millis(10));
448 }
449 // Not yet reaped: the pid is still a zombie here, and still reads as exited.
450 assert_eq!(start_time(child.id()), None);
451 child.wait().unwrap();
452 }
453
454 #[test]
455 fn a_reaped_child_cannot_be_opened_or_observed() {
456 let mut child = spawn_sleep();
457 let pid = child.id();
458 child.kill().unwrap();
459 child.wait().unwrap();
460 // The pid could in principle be reused by now; either way it is not the child.
461 if let Some(process) = Process::open(pid).unwrap() {
462 if let Some(observation) = process.observe() {
463 assert_ne!(observation.executable, Some(sleep_identity()));
464 }
465 }
466 }
467
468 /// The macOS fields are read at fixed offsets, so check the value is a
469 /// plausible start time and not some other field: our own process started
470 /// in the past, and not long ago.
471 #[cfg(target_os = "macos")]
472 #[test]
473 fn macos_start_time_is_microseconds_since_the_epoch() {
474 let now = std::time::SystemTime::now()
475 .duration_since(std::time::UNIX_EPOCH)
476 .unwrap()
477 .as_micros() as u64;
478 let started = start_time(std::process::id()).unwrap();
479 assert!(started <= now, "start time {started} is after now {now}");
480 assert!(
481 now - started < 3_600 * 1_000_000,
482 "start time {started} is more than an hour before now {now}"
483 );
484 }
485
486 /// Keeps one core busy for at least `wall` of wall-clock time.
487 /// This thread's CPU time, from the thread CPU clock rather than the
488 /// process-usage API under test.
489 fn thread_cpu_time() -> Duration {
490 let now = rustix::time::clock_gettime(rustix::time::ClockId::ThreadCPUTime);
491 Duration::new(now.tv_sec as u64, now.tv_nsec as u32)
492 }
493
494 /// Spend `cpu` of this thread's CPU time. Measured on CPU time, not wall
495 /// time: on a loaded machine the thread is descheduled for part of any
496 /// wall interval, so a wall-timed loop can do far less work than its
497 /// duration suggests. A generous wall cap keeps a stalled clock from
498 /// hanging the test.
499 fn burn_cpu(cpu: Duration) {
500 let start = thread_cpu_time();
501 let give_up = Instant::now() + Duration::from_secs(60);
502 let mut value = 0u64;
503 while thread_cpu_time().saturating_sub(start) < cpu {
504 assert!(
505 Instant::now() < give_up,
506 "thread CPU clock stopped advancing"
507 );
508 for step in 0..10_000u64 {
509 value = std::hint::black_box(value.wrapping_mul(31).wrapping_add(step));
510 }
511 }
512 std::hint::black_box(value);
513 }
514
515 #[test]
516 fn own_resource_usage_is_present_and_plausible() {
517 // Clean executable pages need not count toward physical footprint, and
518 // nextest runs this case in a fresh process with little private memory.
519 // Touch and retain private pages so the byte/unit check has a known
520 // lower bound instead of assuming a minimum footprint for the binary.
521 let pages = vec![0xa5u8; 8 * 1024 * 1024];
522 std::hint::black_box(&pages);
523 let usage = resource_usage(std::process::id()).expect("own process is readable");
524 assert!(
525 usage.memory_bytes >= pages.len() as u64,
526 "memory {} bytes cannot account for {} touched private bytes",
527 usage.memory_bytes,
528 pages.len()
529 );
530 std::hint::black_box(&pages);
531 assert!(
532 usage.memory_bytes < 64 * 1024 * 1024 * 1024,
533 "memory {} bytes is implausibly large",
534 usage.memory_bytes
535 );
536 #[cfg(target_os = "macos")]
537 assert_eq!(usage.memory_kind, MemoryKind::PhysFootprint);
538 #[cfg(target_os = "linux")]
539 {
540 assert_eq!(usage.memory_kind, MemoryKind::ResidentSet);
541 assert!(usage.swap_bytes.is_some(), "Linux reports VmSwap");
542 }
543 }
544
545 /// CPU time must grow with busy work, and by roughly the amount of work
546 /// done: a reading in the wrong unit (for example Mach ticks taken as
547 /// nanoseconds on Apple silicon, about 24 times too small) grows too, but
548 /// not by enough.
549 #[test]
550 fn own_cpu_time_grows_by_about_the_busy_work_done() {
551 let pid = std::process::id();
552 let total = |usage: ResourceUsage| usage.cpu_user + usage.cpu_system;
553 let before = total(resource_usage(pid).unwrap());
554 let busy = Duration::from_millis(400);
555 burn_cpu(busy);
556 let after = total(resource_usage(pid).unwrap());
557 let grown = after.saturating_sub(before);
558 // This thread alone spent `busy` of CPU time, so the process total
559 // grew by at least that much; other tests' threads only add to it.
560 // The 10% allowance covers tick rounding in the reading, and is far
561 // tighter than the ~24x a unit error would cause.
562 assert!(
563 grown >= busy * 9 / 10,
564 "cpu time grew by {grown:?} over {busy:?} of busy work"
565 );
566 }
567
568 #[test]
569 fn a_child_reads_its_own_usage_not_ours() {
570 let mut child = spawn_sleep();
571 let process = Process::open(child.id()).unwrap().unwrap();
572 wait_for_executable(&process, sleep_identity());
573 let ours = resource_usage(std::process::id()).unwrap();
574 let usage = resource_usage(child.id()).expect("live child is readable");
575 assert!(usage.memory_bytes > 0);
576 assert!(
577 usage.memory_bytes < ours.memory_bytes,
578 "a sleeping child ({} bytes) should be smaller than the test binary ({} bytes)",
579 usage.memory_bytes,
580 ours.memory_bytes
581 );
582 child.kill().unwrap();
583 child.wait().unwrap();
584 }
585
586 #[test]
587 fn an_exited_child_reads_as_unavailable_not_zero() {
588 let mut child = spawn_sleep();
589 let pid = child.id();
590 child.kill().unwrap();
591 // Killed but not reaped: a zombie, which still has a pid.
592 let deadline = Instant::now() + Duration::from_secs(5);
593 while start_time(pid).is_some() {
594 assert!(Instant::now() < deadline, "child still observed as alive");
595 std::thread::sleep(Duration::from_millis(10));
596 }
597 assert_eq!(resource_usage(pid), None, "a zombie reads as unavailable");
598 child.wait().unwrap();
599 // Reaped: the pid names nothing (barring reuse, which would be some
600 // other live process and so still not a reading of zeros).
601 if let Some(usage) = resource_usage(pid) {
602 assert!(usage.memory_bytes > 0, "a reused pid is some live process");
603 }
604 }
605
606 #[test]
607 fn a_pid_with_no_process_reads_as_unavailable() {
608 // Above both kernels' pid limits (Linux caps pid_max at 2^22, macOS at
609 // 99998), so nothing can hold it.
610 assert_eq!(resource_usage(i32::MAX as u32), None);
611 // Not a representable pid at all.
612 assert_eq!(resource_usage(u32::MAX), None);
613 }
614
615 #[cfg(target_os = "linux")]
616 #[test]
617 fn linux_signals_go_through_a_pidfd() {
618 let mut child = spawn_sleep();
619 let process = Process::open(child.id()).unwrap().unwrap();
620 assert!(process.signals_through_pidfd());
621 child.kill().unwrap();
622 child.wait().unwrap();
623 // The pidfd still names the reaped child, so a signal cannot reach anything else.
624 assert!(!process.signal(Signal::Kill).unwrap());
625 }
626}