From 97a37345cd6a54547c404c715d2771b321fb724b Mon Sep 17 00:00:00 2001 From: MeiK Date: Mon, 23 Mar 2020 19:20:39 +0800 Subject: [PATCH] Update --- src/cgroup.rs | 21 +++++++++++++++++++++ src/main.rs | 15 +++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 src/cgroup.rs diff --git a/src/cgroup.rs b/src/cgroup.rs new file mode 100644 index 0000000..dede4a7 --- /dev/null +++ b/src/cgroup.rs @@ -0,0 +1,21 @@ +use std::result; + +#[derive(Debug)] +pub enum Error { + Error(String), +} + +pub type Result = result::Result; + +pub struct Cgroup { + pid: u32 +} + +impl Cgroup { + pub fn new(pid: u32) -> Result { + return Ok(Cgroup { pid }); + } + pub fn attach(&self) -> Result<()> { + return Ok(()); + } +} diff --git a/src/main.rs b/src/main.rs index 4e42e64..e2b261d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,15 +1,18 @@ +extern crate libc; + +mod cgroup; + use std::process::{Command, Stdio}; +use std::process; use std::io::Read; -use libc; use libc::{time_t, suseconds_t, c_long}; fn main() { run(); - cgroup(); -} - -fn cgroup() { - println!("cgroup"); + match cgroup::Cgroup::new(process::id()) { + Ok(_) => println!("Hello World!"), + Err(e) => println!("{:?}", e), + } } fn run() {