Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sidecar tests testing handling of closed file descriptors #572

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sidecar-ffi/tests/sidecar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 3 additions & 0 deletions spawn_worker/src/unix/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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)]
Expand Down