message: Call execve from fork_and_exec in sys/redox.rs so they can share code
diff: @@ -93,46 +93,6 @@ pub(crate) fn fork_and_exec<F: Fn()>(
  clear_env: bool,
  before_exec: F
  ) -> io::Result<u32> {
  - // Construct a valid set of arguments to pass to execve. Ensure
  - // that the program is the first argument.
  - let mut cvt_args: Vec<[usize; 2]> = Vec::new();
  - cvt_args.push([prog.as_ptr() as usize, prog.len()]);
  - for arg in args {
  - cvt_args.push([arg.as_ptr() as usize, arg.len()]);
  - }
  -
  - // Get the PathBuf of the program if it exists.
  - let prog = if prog.contains(':') || prog.contains('/') {
  - // This is a fully specified scheme or path to an
  - // executable.
  - Some(PathBuf::from(prog))
  - } else if let Ok(paths) = env::var("PATH") {
  - // This is not a fully specified scheme or path.
  - // Iterate through the possible paths in the
  - // env var PATH that this executable may be found
  - // in and return the first one found.
  - env::split_paths(&paths)
  - .filter_map(|mut path| {
  - path.push(prog);
  - if path.exists() {
  - Some(path)
  - } else {
  - None
  - }
  - })
  - .next()
  - } else {
  - None
  - };
  -
  - // If clear_env set, clear the env.
  - if clear_env {
  - for (key, _) in env::vars() {
  - env::remove_var(key);
  - }
  - }
  -
  - if let Some(prog) = prog {
  unsafe {
  match fork()? {
  0 => {
  @@ -153,8 +113,7 @@ pub(crate) fn fork_and_exec<F: Fn()>(
  before_exec();
  - let error = syscall::execve(prog.as_os_str().as_bytes(), &cvt_args);
  - let error = io::Error::from_raw_os_error(error.err().unwrap().errno);
  + let error = execve(prog, args, clear_env);
  eprintln!("ion: command exec: {}", error);
  fork_exit(1);
  }
  @@ -175,10 +134,6 @@ pub(crate) fn fork_and_exec<F: Fn()>(
  }
  }
  }
  - } else {
  - // The binary was not found.
  - Err(io::Error::from_raw_os_error(syscall::ENOENT))
  - }
  }
  pub(crate) fn execve(prog: &str, args: &[&str], clear_env: bool) -> io::Error {
  