Skip to content

Commit 5fa5fd4

Browse files
committed
Auto merge of #357 - arcnmx:exec-void, r=@posborne
Use Void in exec return type Indicates that these methods cannot return successfully. This does introduce a new dependency; an empty enum could be used instead but then you would lose the convenience `unreachable` methods exposed by the `void` crate, and standardizing on one type, etc...
2 parents d2c1263 + cb51657 commit 5fa5fd4

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ preadv_pwritev = []
2323
signalfd = []
2424

2525
[dependencies]
26-
libc = "0.2.8"
26+
libc = "0.2.8"
2727
bitflags = "0.4"
2828
cfg-if = "0.1.0"
29+
void = "1.0.2"
2930

3031
[build-dependencies]
3132
rustc_version = "0.1.7"

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ extern crate bitflags;
1515

1616
#[macro_use]
1717
extern crate cfg_if;
18+
extern crate void;
1819

1920
#[cfg(test)]
2021
extern crate nix_test as nixtest;

src/unistd.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use libc::{self, c_char, c_void, c_int, c_uint, size_t, pid_t, off_t, uid_t, gid
77
use std::mem;
88
use std::ffi::CString;
99
use std::os::unix::io::RawFd;
10+
use void::Void;
1011

1112
#[cfg(any(target_os = "linux", target_os = "android"))]
1213
pub use self::linux::*;
@@ -130,7 +131,7 @@ fn to_exec_array(args: &[CString]) -> Vec<*const c_char> {
130131
}
131132

132133
#[inline]
133-
pub fn execv(path: &CString, argv: &[CString]) -> Result<()> {
134+
pub fn execv(path: &CString, argv: &[CString]) -> Result<Void> {
134135
let args_p = to_exec_array(argv);
135136

136137
unsafe {
@@ -141,7 +142,7 @@ pub fn execv(path: &CString, argv: &[CString]) -> Result<()> {
141142
}
142143

143144
#[inline]
144-
pub fn execve(path: &CString, args: &[CString], env: &[CString]) -> Result<()> {
145+
pub fn execve(path: &CString, args: &[CString], env: &[CString]) -> Result<Void> {
145146
let args_p = to_exec_array(args);
146147
let env_p = to_exec_array(env);
147148

@@ -153,7 +154,7 @@ pub fn execve(path: &CString, args: &[CString], env: &[CString]) -> Result<()> {
153154
}
154155

155156
#[inline]
156-
pub fn execvp(filename: &CString, args: &[CString]) -> Result<()> {
157+
pub fn execvp(filename: &CString, args: &[CString]) -> Result<Void> {
157158
let args_p = to_exec_array(args);
158159

159160
unsafe {

0 commit comments

Comments
 (0)