diff options
Diffstat (limited to 'pkgs/profpatsch/execline')
-rw-r--r-- | pkgs/profpatsch/execline/el_exec.rs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/pkgs/profpatsch/execline/el_exec.rs b/pkgs/profpatsch/execline/el_exec.rs index 25fad36f..0e4e11b7 100644 --- a/pkgs/profpatsch/execline/el_exec.rs +++ b/pkgs/profpatsch/execline/el_exec.rs @@ -12,12 +12,16 @@ fn to_c_argv<S: AsRef<CStr>>(s: &[S]) -> (&[S], Vec<*const libc::c_char>) { /// Exec into argv, or exit 0 if it’s empty. /// Will throw 127 if the executable is not found (ENOENT) /// and 126 for any other exec error. -pub fn xpathexec0<'a, S: AsRef<CStr>>(argv: &'a [S]) { +pub fn xmexec0<'a, S: AsRef<CStr>>(argv: &'a [S]) { let (c_strings, c_argv) = to_c_argv(argv); unsafe { - C::xpathexec0( - c_argv.as_ptr() as *const *const libc::c_char + let env = C::environ; + C::xmexec0_af( + c_argv[0] as *const libc::c_char, + c_argv.as_ptr() as *const *const libc::c_char, + env, + C::env_len(env) ) } } @@ -25,8 +29,15 @@ pub fn xpathexec0<'a, S: AsRef<CStr>>(argv: &'a [S]) { mod C { #[link(name = "skarnet")] extern "C" { - pub fn xpathexec0( - argv: *const *const libc::c_char + pub fn xmexec0_af( + file: *const libc::c_char, + argv: *const *const libc::c_char, + envp: *const *const libc::c_char, + envlen: libc::size_t ); + pub static environ: *const *const libc::c_char; + pub fn env_len( + e: *const *const libc::c_char + ) -> libc::size_t; } } |