feat: return more relevant values
This commit is contained in:
parent
9c98e8bd52
commit
2a10226a0e
1 changed files with 10 additions and 6 deletions
|
@ -169,11 +169,13 @@ pub fn lua_procmaps(lua: &Lua, ret: Option<bool>) -> Result<Value, Error> {
|
||||||
}
|
}
|
||||||
Ok(out.to_lua(lua)?)
|
Ok(out.to_lua(lua)?)
|
||||||
} else {
|
} else {
|
||||||
let mut out = format!("=> /proc/{}/maps", std::process::id());
|
let mut out = String::new();
|
||||||
|
let mut count = 0;
|
||||||
for map in maps {
|
for map in maps {
|
||||||
|
count += 1;
|
||||||
out.push_str(
|
out.push_str(
|
||||||
format!(
|
format!(
|
||||||
"\n[{}] 0x{:08X}..0x{:08X} +{:08x} ({}b) \t {:?} {}",
|
" * [{}] 0x{:08X}..0x{:08X} +{:08x} ({}b) \t {:?} {}\n",
|
||||||
map.perms.as_str(), map.address.0, map.address.1, map.offset, map.address.1 - map.address.0, map.pathname,
|
map.perms.as_str(), map.address.0, map.address.1, map.offset, map.address.1 - map.address.0, map.pathname,
|
||||||
if map.inode != 0 { format!("({})", map.inode) } else { "".into() },
|
if map.inode != 0 { format!("({})", map.inode) } else { "".into() },
|
||||||
).as_str()
|
).as_str()
|
||||||
|
@ -181,7 +183,7 @@ pub fn lua_procmaps(lua: &Lua, ret: Option<bool>) -> Result<Value, Error> {
|
||||||
}
|
}
|
||||||
let console : Console = lua.globals().get(GLOBAL_CONSOLE)?;
|
let console : Console = lua.globals().get(GLOBAL_CONSOLE)?;
|
||||||
console.send(out)?;
|
console.send(out)?;
|
||||||
Ok(Value::Nil)
|
Ok(Value::Integer(count))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,12 +210,14 @@ pub fn lua_threads(lua: &Lua, ret: Option<bool>) -> Result<Value, Error> {
|
||||||
}
|
}
|
||||||
Ok(out.to_lua(lua)?)
|
Ok(out.to_lua(lua)?)
|
||||||
} else {
|
} else {
|
||||||
let mut out = format!("=> /proc/{}/tasks", std::process::id());
|
let mut out = String::new();
|
||||||
|
let mut count = 0;
|
||||||
for task in maps {
|
for task in maps {
|
||||||
match thread_status(task) {
|
match thread_status(task) {
|
||||||
Ok(s) => {
|
Ok(s) => {
|
||||||
|
count += 1;
|
||||||
out.push_str(
|
out.push_str(
|
||||||
format!("\n * [{}] {} {} | {} fd)", s.pid, s.state, s.name, s.fdsize).as_str()
|
format!(" * [{}] {} {} | {} fd)\n", s.pid, s.state, s.name, s.fdsize).as_str()
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
Err(e) => warn!("could not parse task metadata: {}", e),
|
Err(e) => warn!("could not parse task metadata: {}", e),
|
||||||
|
@ -222,7 +226,7 @@ pub fn lua_threads(lua: &Lua, ret: Option<bool>) -> Result<Value, Error> {
|
||||||
|
|
||||||
let console : Console = lua.globals().get(GLOBAL_CONSOLE)?;
|
let console : Console = lua.globals().get(GLOBAL_CONSOLE)?;
|
||||||
console.send(out)?;
|
console.send(out)?;
|
||||||
Ok(Value::Nil)
|
Ok(Value::Integer(count))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue