Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions src/sandbox/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod cgroup;
mod resource;

use std::{io, os::unix::process::ExitStatusExt, process, time::Duration};
use std::{io, os::unix::process::ExitStatusExt, time::Duration};

use tokio::{
process::{Child, Command},
Expand Down Expand Up @@ -46,19 +46,7 @@ impl Sandbox {
}

pub fn spawn(&self, mut command: Command) -> io::Result<Child> {
let cgroup = self.cgroup.clone();

unsafe {
command
.pre_exec(move || {
let id = process::id();

cgroup
.add_task_by_tgid(CgroupPid::from(id as u64))
.map_err(io::Error::other)
})
.spawn()
}
command.spawn()
}

pub async fn monitor(&self, mut child: Child) -> io::Result<(Option<Verdict>, Duration, Byte)> {
Expand Down
Loading