mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-08 21:06:48 +00:00
Clarify some API usages
This commit is contained in:
parent
a993264265
commit
d0719efcb4
@ -85,17 +85,13 @@ impl FileOps for StatFileOps {
|
||||
|
||||
let pid = process.pid();
|
||||
let comm = process.executable_path();
|
||||
let ppid = process.parent().pid();
|
||||
let state = if process.status().is_zombie() {
|
||||
'Z'
|
||||
} else {
|
||||
'R'
|
||||
};
|
||||
let pgrp = if let Some(pgrp) = process.process_group() {
|
||||
pgrp.pgid()
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let ppid = process.parent().pid();
|
||||
let pgrp = process.pgid();
|
||||
|
||||
let mut stat_output = String::new();
|
||||
writeln!(
|
||||
|
@ -166,7 +166,7 @@ fn current_thread_sender_ids(signum: Option<&SigNum>, ctx: &Context) -> SignalSe
|
||||
let euid = credentials.euid();
|
||||
let sid = signum.and_then(|signum| {
|
||||
if *signum == SIGCONT {
|
||||
Some(ctx.process.session().unwrap().sid())
|
||||
Some(ctx.process.sid())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ impl PosixThread {
|
||||
if let Some(signum) = signum
|
||||
&& *signum == SIGCONT
|
||||
{
|
||||
let receiver_sid = self.process().session().unwrap().sid();
|
||||
let receiver_sid = self.process().sid();
|
||||
if receiver_sid == sender.sid().unwrap() {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -344,11 +344,6 @@ impl Process {
|
||||
|
||||
// *********** Process group & Session ***********
|
||||
|
||||
/// Returns the process group to which the process belongs.
|
||||
pub fn process_group(&self) -> Option<Arc<ProcessGroup>> {
|
||||
self.process_group.lock().upgrade()
|
||||
}
|
||||
|
||||
/// Returns the process group ID of the process.
|
||||
//
|
||||
// FIXME: If we call this method without holding the process table lock, it may return zero if
|
||||
@ -365,9 +360,27 @@ impl Process {
|
||||
self.session().map_or(0, |session| session.sid())
|
||||
}
|
||||
|
||||
/// Returns the process group to which the process belongs.
|
||||
///
|
||||
/// **Deprecated:** This is a very poorly designed API. Almost every use of this API is wrong
|
||||
/// because some race condition is not handled correctly. Such usages are being refactored and
|
||||
/// this API will be removed soon. So DO NOT ATTEMPT TO USE THIS API IN NEW CODE unless you
|
||||
/// know exactly what you're doing.
|
||||
pub fn process_group(&self) -> Option<Arc<ProcessGroup>> {
|
||||
self.process_group.lock().upgrade()
|
||||
}
|
||||
|
||||
/// Returns the session to which the process belongs.
|
||||
///
|
||||
/// **Deprecated:** This is a very poorly designed API. Almost every use of this API is wrong
|
||||
/// because some race condition is not handled correctly. Such usages are being refactored and
|
||||
/// this API will be removed soon. So DO NOT ATTEMPT TO USE THIS API IN NEW CODE unless you
|
||||
/// know exactly what you're doing.
|
||||
pub fn session(&self) -> Option<Arc<Session>> {
|
||||
self.process_group()?.session()
|
||||
self.process_group
|
||||
.lock()
|
||||
.upgrade()
|
||||
.and_then(|group| group.session())
|
||||
}
|
||||
|
||||
/// Returns whether the process is session leader.
|
||||
|
Loading…
x
Reference in New Issue
Block a user