Skip to content

Commit 5336ca0

Browse files
committed
Polyfill posix_spawn_file_actions_addchdir_np
Signed-off-by: Bob Weinand <[email protected]>
1 parent e5a35a3 commit 5336ca0

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components-rs/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ serde_json = "1.0.113"
4545
regex = "1.10.5"
4646
regex-automata = "0.4.5"
4747
http = "1.0"
48+
libc = "0.2"
4849

4950
[build-dependencies]
5051
cbindgen = "0.27"

components-rs/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,16 @@ pub extern "C" fn ddog_library_configurator_new_dummy(
9494
) -> Box<Configurator> {
9595
datadog_library_config_ffi::ddog_library_configurator_new(debug_logs, language)
9696
}
97+
98+
// Starting with https://github.com/rust-lang/rust/commit/7f74c894b0e31f370b5321d94f2ca2830e1d30fd
99+
// rust assumes posix_spawn_file_actions_addchdir_np exists. Thus we need to polyfill it here.
100+
#[no_mangle]
101+
#[cfg(all(target_os = "linux", target_env = "musl"))]
102+
pub unsafe extern "C" fn posix_spawn_file_actions_addchdir_np(file_actions: *mut libc::c_void, path: *const libc::c_char) -> libc::c_int {
103+
let sym = std::mem::transmute::<*mut libc::c_void, std::option::Option<extern "C" fn(*mut libc::c_void, *const libc::c_char) -> libc::c_int>>(libc::dlsym(null_mut(), c"posix_spawn_file_actions_addchdir_np".as_ptr()));
104+
if let Some(sym) = sym {
105+
sym(file_actions, path)
106+
} else {
107+
-libc::ENOSYS
108+
}
109+
}

0 commit comments

Comments
 (0)