Skip to content

Commit

Permalink
Add fexecve cfg attribute for OpenBSD
Browse files Browse the repository at this point in the history
fexecve doesn't exist on OpenBSD so add conditional compilation for it
in unistd and in related tests.

The only "reference" that I could find is a mention that fexecve is
not implemented on OpenBSD in the manual pages for signal(3) and
sigaction(2):

Official repository (search for "fexecve"):
https://cvsweb.openbsd.org/src/lib/libc/sys/sigaction.2?rev=1.75&content-type=text/x-cvsweb-markup

Github mirror:
https://github.com/openbsd/src/blob/master/lib/libc/sys/sigaction.2#L619
  • Loading branch information
thendiscard committed Dec 20, 2018
1 parent 85ae87c commit 680ff30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,7 @@ pub fn execvpe(filename: &CString, args: &[CString], env: &[CString]) -> Result<
#[cfg(any(target_os = "android",
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd"))]
target_os = "netbsd"))]
#[inline]
pub fn fexecve(fd: RawFd, args: &[CString], env: &[CString]) -> Result<Void> {
let args_p = to_exec_array(args);
Expand Down
8 changes: 4 additions & 4 deletions test/test_unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,16 @@ cfg_if!{
execve_test_factory!(test_execve, execve, &CString::new("/system/bin/sh").unwrap());
execve_test_factory!(test_fexecve, fexecve, File::open("/system/bin/sh").unwrap().into_raw_fd());
} else if #[cfg(any(target_os = "freebsd",
target_os = "linux",
target_os = "openbsd"))] {
target_os = "linux"))] {
execve_test_factory!(test_execve, execve, &CString::new("/bin/sh").unwrap());
execve_test_factory!(test_fexecve, fexecve, File::open("/bin/sh").unwrap().into_raw_fd());
} else if #[cfg(any(target_os = "dragonfly",
target_os = "ios",
target_os = "macos",
target_os = "netbsd"))] {
target_os = "netbsd",
target_os = "openbsd"))] {
execve_test_factory!(test_execve, execve, &CString::new("/bin/sh").unwrap());
// No fexecve() on DragonFly, ios, macos, and NetBSD.
// No fexecve() on DragonFly, ios, macos, NetBSD, OpenBSD.
}
}

Expand Down

0 comments on commit 680ff30

Please sign in to comment.