From e19e0a4e7a85978eeaf1b01393e1aea528bc8cd8 Mon Sep 17 00:00:00 2001 From: Omar Abdulla Date: Fri, 15 Aug 2025 16:16:36 +0300 Subject: [PATCH] Fix the OS FD error --- crates/compiler/src/revive_resolc.rs | 29 +++++++++++++++++----------- crates/compiler/src/solc.rs | 25 +++++++++++++++--------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/crates/compiler/src/revive_resolc.rs b/crates/compiler/src/revive_resolc.rs index 0261de8..6f0246e 100644 --- a/crates/compiler/src/revive_resolc.rs +++ b/crates/compiler/src/revive_resolc.rs @@ -2,6 +2,7 @@ //! compiling contracts to PolkaVM (PVM) bytecode. use std::{ + os::unix::process::CommandExt, path::PathBuf, process::{Command, Stdio}, }; @@ -92,11 +93,14 @@ impl SolidityCompiler for Resolc { }; let mut command = AsyncCommand::new(&self.resolc_path); - command - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .arg("--standard-json"); + unsafe { + command + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .arg("--standard-json") + .pre_exec(|| Ok(())) + }; if let Some(ref base_path) = base_path { command.arg("--base-path").arg(base_path); @@ -215,12 +219,15 @@ impl SolidityCompiler for Resolc { // Logic for parsing the resolc version from the following string: // Solidity frontend for the revive compiler version 0.3.0+commit.b238913.llvm-18.1.8 - let output = Command::new(self.resolc_path.as_path()) - .arg("--version") - .stdout(Stdio::piped()) - .spawn()? - .wait_with_output()? - .stdout; + let output = unsafe { + Command::new(self.resolc_path.as_path()) + .arg("--version") + .stdout(Stdio::piped()) + .pre_exec(|| Ok(())) + .spawn()? + .wait_with_output()? + .stdout + }; let output = String::from_utf8_lossy(&output); let version_string = output .split("version ") diff --git a/crates/compiler/src/solc.rs b/crates/compiler/src/solc.rs index f714857..ad3f6a1 100644 --- a/crates/compiler/src/solc.rs +++ b/crates/compiler/src/solc.rs @@ -2,6 +2,7 @@ //! compiling contracts to EVM bytecode. use std::{ + os::unix::process::CommandExt, path::PathBuf, process::{Command, Stdio}, }; @@ -102,11 +103,14 @@ impl SolidityCompiler for Solc { }; let mut command = AsyncCommand::new(&self.solc_path); - command - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .arg("--standard-json"); + unsafe { + command + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .arg("--standard-json") + .pre_exec(|| Ok(())) + }; if let Some(ref base_path) = base_path { command.arg("--base-path").arg(base_path); @@ -205,10 +209,13 @@ impl SolidityCompiler for Solc { // Version: 0.8.30+commit.73712a01.Darwin.appleclang // ``` - let child = Command::new(self.solc_path.as_path()) - .arg("--version") - .stdout(Stdio::piped()) - .spawn()?; + let child = unsafe { + Command::new(self.solc_path.as_path()) + .arg("--version") + .stdout(Stdio::piped()) + .pre_exec(|| Ok(())) + .spawn() + }?; let output = child.wait_with_output()?; let output = String::from_utf8_lossy(&output.stdout); let version_line = output