Commit add9c4b2 authored by Cyril Plisko's avatar Cyril Plisko 🤔

Add errno

parent bcfc0fd5
Pipeline #4860065 failed with stage
in 3 minutes
......@@ -11,4 +11,5 @@ repository = "https://gitlab.com/imp/pager-rs.git"
version = "0.9.3"
[dependencies]
errno = "0.1.8"
libc = "0.2"
......@@ -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;
......
......@@ -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) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment