Skip to content

Commit d4eaaf3

Browse files
authored
chore(solc): use exec on unices (#135)
Less overhead
1 parent b99dd2a commit d4eaaf3

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

crates/svm-rs/src/bin/solc/main.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
1010

1111
use anyhow::Context;
12-
use std::process::{Command, Stdio};
12+
use std::io;
13+
use std::process::{Command, ExitStatus, Stdio};
1314

1415
fn main() {
1516
let code = match main_() {
@@ -54,11 +55,22 @@ fn main_() -> anyhow::Result<i32> {
5455
);
5556
}
5657

57-
let status = Command::new(bin)
58-
.args(args)
58+
let mut cmd = Command::new(bin);
59+
cmd.args(args)
5960
.stdin(Stdio::inherit())
6061
.stdout(Stdio::inherit())
61-
.stderr(Stdio::inherit())
62-
.status()?;
63-
Ok(status.code().unwrap_or(-1))
62+
.stderr(Stdio::inherit());
63+
Ok(exec(&mut cmd)?.code().unwrap_or(-1))
64+
}
65+
66+
fn exec(cmd: &mut Command) -> io::Result<ExitStatus> {
67+
#[cfg(unix)]
68+
{
69+
use std::os::unix::prelude::*;
70+
Err(cmd.exec())
71+
}
72+
#[cfg(not(unix))]
73+
{
74+
cmd.status()
75+
}
6476
}

0 commit comments

Comments
 (0)