diff --git a/Cargo.lock b/Cargo.lock index 2ac962772..d78a65543 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -374,6 +374,11 @@ dependencies = [ "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "exitcode" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "failure" version = "0.1.5" @@ -1166,6 +1171,7 @@ dependencies = [ "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "exitcode 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "flame 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "flamer 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2055,6 +2061,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b" "checksum ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f56c93cc076508c549d9bb747f79aa9b4eb098be7b8cad8830c3137ef52d1e00" "checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" +"checksum exitcode 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "de853764b47027c2e862a995c34978ffa63c1501f2e15f987ba11bd4f9bba193" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" diff --git a/vm/Cargo.toml b/vm/Cargo.toml index d6f872e0a..2ded048f5 100644 --- a/vm/Cargo.toml +++ b/vm/Cargo.toml @@ -71,6 +71,9 @@ flamer = { version = "0.3", optional = true } [target.'cfg(all(unix, not(any(target_os = "android", target_os = "redox"))))'.dependencies] pwd = "1" +[target.'cfg(unix)'.dependencies] +exitcode = "1.1.2" + [target.'cfg(not(target_arch = "wasm32"))'.dependencies] crc32fast = "1.2.0" adler32 = "1.0.3" diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index e4cde6256..6c9a892a7 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -11,6 +11,8 @@ use std::os::windows::fs::OpenOptionsExt; use std::time::{Duration, SystemTime}; use std::{env, fs}; +#[cfg(unix)] +use exitcode; #[cfg(unix)] use nix::errno::Errno; #[cfg(all(unix, not(target_os = "redox")))] @@ -1292,6 +1294,22 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: PyObjectRef) -> "SEEK_SET" => ctx.new_int(Whence::SeekSet as i8), "SEEK_CUR" => ctx.new_int(Whence::SeekCur as i8), "SEEK_END" => ctx.new_int(Whence::SeekEnd as i8), + "EX_OK" => ctx.new_int(exitcode::OK as i8), + "EX_USAGE" => ctx.new_int(exitcode::USAGE as i8), + "EX_DATAERR" => ctx.new_int(exitcode::DATAERR as i8), + "EX_NOINPUT" => ctx.new_int(exitcode::NOINPUT as i8), + "EX_NOUSER" => ctx.new_int(exitcode::NOUSER as i8), + "EX_NOHOST" => ctx.new_int(exitcode::NOHOST as i8), + "EX_UNAVAILABLE" => ctx.new_int(exitcode::UNAVAILABLE as i8), + "EX_SOFTWARE" => ctx.new_int(exitcode::SOFTWARE as i8), + "EX_OSERR" => ctx.new_int(exitcode::OSERR as i8), + "EX_OSFILE" => ctx.new_int(exitcode::OSFILE as i8), + "EX_CANTCREAT" => ctx.new_int(exitcode::CANTCREAT as i8), + "EX_IOERR" => ctx.new_int(exitcode::IOERR as i8), + "EX_TEMPFAIL" => ctx.new_int(exitcode::TEMPFAIL as i8), + "EX_PROTOCOL" => ctx.new_int(exitcode::PROTOCOL as i8), + "EX_NOPERM" => ctx.new_int(exitcode::NOPERM as i8), + "EX_CONFIG" => ctx.new_int(exitcode::CONFIG as i8), }); #[cfg(not(target_os = "redox"))]