Make Fixture::drop send a valid exit code ptr to the stream

Found a good way to avoid both an extra function to RunData and make calling `xwayland_exit_code` in other RunData types *less* prone to memory violations. Having a function with a non-empty default implementation being overridden by an empty implementation felt too awkward.
This commit is contained in:
En-En 2025-03-15 01:25:00 +00:00 committed by Shawn Wallace
parent 5bbc4c507a
commit f9ec97b007
2 changed files with 5 additions and 8 deletions

View file

@ -89,7 +89,8 @@ impl Drop for Fixture {
let thread = unsafe { ManuallyDrop::take(&mut self.thread) };
// Sending anything to the quit receiver to stop the main loop. Then we guarantee a main
// thread does not use file descriptors which outlive the Fixture's BorrowedFd
self.quit_tx.write_all(&1_usize.to_ne_bytes()).unwrap();
let return_ptr = Box::into_raw(Box::new(0_usize)) as usize;
self.quit_tx.write_all(&return_ptr.to_ne_bytes()).unwrap();
thread.join().expect("Main thread panicked");
rustix::process::kill_process(self.pid, Signal::Term).unwrap();
rustix::process::waitpid(Some(self.pid), WaitOptions::NOHANG).unwrap();