Skip to content

Commit ca63650

Browse files
committed
Auto merge of #30082 - semarie:execve, r=alexcrichton
under OpenBSD and Bitrig, it is an error to pass an empty argv argument to execve(2). It results the test fail as execve(2) don't exec and set errno to EINVAL. instead, make argv with two arguments (in order to differenciate the initial call, from the execve call). r? @alexcrichton
2 parents e5aa92a + efc17a5 commit ca63650

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/test/run-pass/env-funky-keys.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use std::ffi::OsStr;
2626
use std::ptr;
2727

2828
fn main() {
29-
if env::args_os().next().is_none() {
29+
if env::args_os().count() == 2 {
3030
for (key, value) in env::vars_os() {
3131
panic!("found env value {:?} {:?}", key, value);
3232
}
@@ -36,7 +36,7 @@ fn main() {
3636
let current_exe = env::current_exe().unwrap().into_os_string().to_cstring().unwrap();
3737
let new_env_var = OsStr::new("FOOBAR").to_cstring().unwrap();
3838
let filename: *const c_char = current_exe.as_ptr();
39-
let argv: &[*const c_char] = &[ptr::null()];
39+
let argv: &[*const c_char] = &[filename, filename, ptr::null()];
4040
let envp: &[*const c_char] = &[new_env_var.as_ptr(), ptr::null()];
4141
unsafe {
4242
execve(filename, &argv[0], &envp[0]);

0 commit comments

Comments
 (0)