Support reading context status.
This commit is contained in:
@@ -1155,6 +1155,18 @@ impl ContextHandle {
|
||||
buf.copy_exactly(crate::cpu_set::mask_as_bytes(&mask))?;
|
||||
Ok(mem::size_of_val(&mask))
|
||||
} // TODO: Replace write() with SYS_SENDFD?
|
||||
ContextHandle::Status => {
|
||||
let status = match context.read().status {
|
||||
Status::Runnable => ContextStatus::Runnable,
|
||||
Status::Blocked => ContextStatus::Blocked,
|
||||
Status::Dead => ContextStatus::Dead,
|
||||
Status::HardBlocked {
|
||||
reason: HardBlockedReason::NotYetStarted,
|
||||
} => ContextStatus::NotYetStarted,
|
||||
_ => ContextStatus::Other,
|
||||
};
|
||||
buf.copy_common_bytes_from_slice(&(status as usize).to_ne_bytes())
|
||||
}
|
||||
ContextHandle::Attr => {
|
||||
let (euid, egid, ens, pid) = match context.read() {
|
||||
ref c => (c.euid, c.egid, c.ens.get() as u32, c.pid as u32),
|
||||
|
||||
Reference in New Issue
Block a user