From 396750c2da1f853e6556c264da75ff57a7af9452 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 23 Apr 2019 13:45:20 -0600 Subject: [PATCH] Fixes for building with Redox in the unix target family --- Cargo.lock | 2 ++ src/main.rs | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cf11d8bcfc..f49f7542da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,3 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. [[package]] name = "init" version = "0.1.0" diff --git a/src/main.rs b/src/main.rs index 745d16f57a..4d721e2ca0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,25 +5,25 @@ extern crate syscall; use std::env; use std::fs::{File, read_dir}; use std::io::{Read, Error, Result}; -use std::os::unix::io::{AsRawFd, FromRawFd}; +use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use std::path::Path; use std::process::Command; use syscall::flag::{O_RDONLY, O_WRONLY}; fn switch_stdio(stdio: &str) -> Result<()> { let stdin = unsafe { File::from_raw_fd( - syscall::open(stdio, O_RDONLY).map_err(|err| Error::from_raw_os_error(err.errno))? + syscall::open(stdio, O_RDONLY).map_err(|err| Error::from_raw_os_error(err.errno))? as RawFd ) }; let stdout = unsafe { File::from_raw_fd( - syscall::open(stdio, O_WRONLY).map_err(|err| Error::from_raw_os_error(err.errno))? + syscall::open(stdio, O_WRONLY).map_err(|err| Error::from_raw_os_error(err.errno))? as RawFd ) }; let stderr = unsafe { File::from_raw_fd( - syscall::open(stdio, O_WRONLY).map_err(|err| Error::from_raw_os_error(err.errno))? + syscall::open(stdio, O_WRONLY).map_err(|err| Error::from_raw_os_error(err.errno))? as RawFd ) }; - syscall::dup2(stdin.as_raw_fd(), 0, &[]).map_err(|err| Error::from_raw_os_error(err.errno))?; - syscall::dup2(stdout.as_raw_fd(), 1, &[]).map_err(|err| Error::from_raw_os_error(err.errno))?; - syscall::dup2(stderr.as_raw_fd(), 2, &[]).map_err(|err| Error::from_raw_os_error(err.errno))?; + syscall::dup2(stdin.as_raw_fd() as usize, 0, &[]).map_err(|err| Error::from_raw_os_error(err.errno))?; + syscall::dup2(stdout.as_raw_fd() as usize, 1, &[]).map_err(|err| Error::from_raw_os_error(err.errno))?; + syscall::dup2(stderr.as_raw_fd() as usize, 2, &[]).map_err(|err| Error::from_raw_os_error(err.errno))?; Ok(()) }