Add sys:exe to get current executable
This commit is contained in:
parent
61871c6071
commit
a916e29b3c
1 changed files with 18 additions and 0 deletions
16
kernel/scheme/sys/exe.rs
Normal file
16
kernel/scheme/sys/exe.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
use collections::Vec;
|
||||
|
||||
use context;
|
||||
use syscall::error::{Error, ESRCH, Result};
|
||||
|
||||
pub fn resource() -> Result<Vec<u8>> {
|
||||
let mut name = {
|
||||
let contexts = context::contexts();
|
||||
let context_lock = contexts.current().ok_or(Error::new(ESRCH))?;
|
||||
let context = context_lock.read();
|
||||
let name = context.name.lock();
|
||||
name.clone()
|
||||
};
|
||||
name.push(b'\n');
|
||||
Ok(name)
|
||||
}
|
||||
Loading…
Reference in a new issue