Skip to content

Commit 73045fb

Browse files
committed
refactor: remove nix
1 parent 41ac77e commit 73045fb

3 files changed

Lines changed: 5 additions & 6 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ A code runner library for online judge system
1414
bon = "3.8.1"
1515
byte-unit = "5.2.0"
1616
cgroups-rs = "0.5.0"
17-
nix = { version = "0.30.1", default-features = false, features = ["signal"] }
1817
state-shift = "2.1.1"
1918
timeout-readwrite = "0.4.0"
2019
uuid = { version = "1.19.0", features = ["v4", "fast-rng"] }

src/sandbox/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ mod resource;
44
use std::{
55
io,
66
os::unix::process::{CommandExt, ExitStatusExt},
7+
process,
78
process::{Child, Command},
89
thread::sleep,
910
time::{Duration, Instant},
@@ -14,7 +15,6 @@ use cgroups_rs::{
1415
CgroupPid,
1516
fs::{Cgroup, cpu::CpuController, memory::MemController},
1617
};
17-
use nix::{libc::getpid, sys::signal::Signal};
1818
pub use resource::Resource;
1919

2020
use crate::{
@@ -48,7 +48,7 @@ impl Sandbox {
4848
unsafe {
4949
command
5050
.pre_exec(move || {
51-
let id = getpid();
51+
let id = process::id();
5252

5353
cgroup
5454
.add_task_by_tgid(CgroupPid::from(id as u64))
@@ -114,8 +114,9 @@ impl Sandbox {
114114
if status.success() {
115115
return Ok((None, prev_cpu_usage, memory_usage));
116116
}
117-
match status.signal().and_then(|x| Signal::try_from(x).ok()) {
118-
Some(Signal::SIGKILL) => Ok((
117+
match status.signal() {
118+
// SIGKILL
119+
Some(9) => Ok((
119120
Some(Verdict::MemoryLimitExceeded),
120121
prev_cpu_usage,
121122
memory.limit(),

0 commit comments

Comments
 (0)