diff options
author | Cyril Plisko <cyril.plisko@mountall.com> | 2016-11-03 18:51:19 +0200 |
---|---|---|
committer | Cyril Plisko <cyril.plisko@mountall.com> | 2016-11-03 20:31:19 +0200 |
commit | add9c4b27a71e295381297bcd6d0ad69e7ebeaf8 (patch) | |
tree | ea94fb81e39ded7b620afba2cf7d4a5aa52ee9aa /src | |
parent | bcfc0fd5db0cee241dd61f0afab114359852d544 (diff) |
Add errno
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 1 | ||||
-rw-r--r-- | src/utils.rs | 11 |
2 files changed, 11 insertions, 1 deletions
@@ -38,6 +38,7 @@ //! will skip initialization. The host application will continue as normal. `Pager::ok()` will //! reflect the fact that no Pager is active. +extern crate errno; extern crate libc; mod utils; diff --git a/src/utils.rs b/src/utils.rs index fc5fdfe..8abd39b 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -3,6 +3,7 @@ use std::ffi::{CString, OsString}; use std::os::unix::ffi::OsStringExt; use std::ptr; +use errno; use libc; fn osstring2cstring(s: &OsString) -> CString { @@ -22,12 +23,20 @@ pub fn fork() -> libc::pid_t { } pub fn execvp(cmd: &OsString) { + // println!("cmd {:?}", cmd); let mut args = Vec::with_capacity(2); for arg in split_string(cmd) { + // println!("arg {:?}", arg); args.push(osstring2cstring(&arg).as_ptr()) } args.push(ptr::null()); - assert!(unsafe { libc::execvp(args[0], args.as_ptr()) } > -1); + // println!("args {:?}", args); + errno::set_errno(errno::Errno(0)); + // println!("errno pre {}", errno::errno()); + // println!("Going to run execvp({:?}, {:?})", args[0], args.as_ptr()); + unsafe { libc::execvp(args[0], args.as_ptr()) }; + // println!("errno post {}", errno::errno()); + assert!(false); } pub fn dup2(fd1: i32, fd2: i32) { |