Skip to content

Commit

Permalink
Add compile timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
slhmy committed Oct 1, 2024
1 parent af19251 commit 473034f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions judge-core/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ const TEMPLATE_ARG_SRC_PATH: &str = "{src_path}";
const TEMPLATE_ARG_TARGET_PATH: &str = "{target_path}";

const RUST_COMPILE_COMMAND_TEMPLATE: &str = "rustc {src_path} -o {target_path}";
const CPP_COMPILE_COMMAND_TEMPLATE: &str =
"g++ -fmax-include-depth=10 {src_path} -o {target_path} -O2 -static";
const CPP_COMPILE_COMMAND_TEMPLATE: &str = "g++ {src_path} -o {target_path} -O2 -static";
const PYTHON_COMPILE_COMMAND_TEMPLATE: &str = "cp {src_path} {target_path}";

#[derive(Clone)]
Expand Down Expand Up @@ -163,7 +162,9 @@ impl Compiler {
std::fs::remove_file(target_path)?;
}

let output = Command::new("sh")
let output = Command::new("timeout")
.arg("30s") // TODO: make timeout configurable
.arg("sh")
.arg("-c")
.arg(
self.command_builder
Expand Down

0 comments on commit 473034f

Please sign in to comment.