From ce619b7619eacbcd75f3dabb2743ff4a8ecba7b4 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Fri, 2 Aug 2024 18:00:55 +0200 Subject: [PATCH] Fix test_ddog_ph_file_handling sidecar test Signed-off-by: Bob Weinand --- sidecar-ffi/tests/sidecar.rs | 1 + spawn_worker/src/unix/fork.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/sidecar-ffi/tests/sidecar.rs b/sidecar-ffi/tests/sidecar.rs index 4c0573830..25dd11f9c 100644 --- a/sidecar-ffi/tests/sidecar.rs +++ b/sidecar-ffi/tests/sidecar.rs @@ -44,6 +44,7 @@ fn test_ddog_ph_file_handling() { let mut file = unsafe { File::from_raw_fd(fd) }; writeln!(file, "test").unwrap_err(); // file is closed, so write returns an error + std::mem::forget(file); // leak to avoid debug runtime SIGABRT: "file descriptor already closed" } #[test] diff --git a/spawn_worker/src/unix/fork.rs b/spawn_worker/src/unix/fork.rs index 8302c7af8..fdef6e1f9 100644 --- a/spawn_worker/src/unix/fork.rs +++ b/spawn_worker/src/unix/fork.rs @@ -64,6 +64,7 @@ mod single_threaded_tests { use io_lifetimes::OwnedFd; use std::{ io::{Read, Write}, + mem::forget, os::unix::{ net::UnixStream, prelude::{AsRawFd, FromRawFd}, @@ -106,6 +107,8 @@ mod single_threaded_tests { assert_child_exit!(pid); assert_eq!(format!("child-{pid}"), out); + + forget(sock_b); // leak to avoid debug runtime SIGABRT: "file descriptor already closed" } #[cfg(unix)]