diff --git a/alvokanto/src/main.rs b/alvokanto/src/main.rs index 2a09bc43de92d87d2d7e321ead2be20776198e3f..e6a60aa9be6bf3b23cf0dbbac549d13ba64d9a3b 100644 --- a/alvokanto/src/main.rs +++ b/alvokanto/src/main.rs @@ -381,7 +381,7 @@ fn judge( let judge_start_instant = Local::now().naive_utc(); - let mut binary_file = request.source_text.as_bytes().to_vec(); + let mut binary_bytes = request.source_text.as_bytes().to_vec(); if let Compile::Command(transform, command, _) = &language.compile { isolate::reset(isolate_executable_path, isolate_box.id).expect("Reset failed"); @@ -450,7 +450,7 @@ fn judge( }; } - binary_file = fs::read( + binary_bytes = fs::read( isolate_box.path.join( language .run @@ -505,7 +505,7 @@ fn judge( let mut perms = file.metadata().unwrap().permissions(); perms.set_mode(0o755); file.set_permissions(perms).unwrap(); - file.write_all(&binary_file).unwrap(); + file.write_all(&binary_bytes).unwrap(); } let execute_stats = isolate::execute( isolate_executable_path, @@ -540,8 +540,12 @@ fn judge( break; } + let output_bytes = fs::read(&execute_stats.stdout_path).unwrap(); isolate::reset(isolate_executable_path, isolate_box.id).expect("Reset failed"); - fs::copy(&execute_stats.stdout_path, isolate_box.path.join("stdin")).expect("Copy"); + { + let mut file = File::create(isolate_box.path.join("stdin")).unwrap(); + file.write_all(&output_bytes).unwrap(); + } last_execute_stats = Some(execute_stats); // TODO: Support non-compile based languages