Skip to content

Commit 3df15ef

Browse files
committed
process: Fix missing items
1 parent 272d06d commit 3df15ef

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

kernel/src/process/mod.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub struct Process {
5050
/// The display name of this process.
5151
name: String,
5252
/// The parent of this process, or [`None`], if this is the init process.
53-
parent: Option<Weak<Process>>,
53+
parent: SpinMutex<Option<Weak<Process>>>,
5454
/// A list of [`Task`]s associated with this process.
5555
pub threads: SpinMutex<Vec<Arc<Task>>>,
5656
/// The address space for this process.
@@ -123,12 +123,7 @@ impl Process {
123123
/// Gets the parent process of this process.
124124
/// Returns [`None`], if it is the init process.
125125
pub fn get_parent(&self) -> Option<Arc<Self>> {
126-
// TODO: The upgrade should never fail.
127-
// If it does, then somehow the child was alive but the parent was not.
128-
self.parent.as_ref().map(|x| {
129-
x.upgrade()
130-
.expect("FIXME: Child process was alive for longer than the parent")
131-
})
126+
self.parent.lock().as_ref().and_then(Weak::upgrade)
132127
}
133128

134129
pub fn new(name: String, parent: Option<Arc<Self>>) -> EResult<Self> {
@@ -139,7 +134,7 @@ impl Process {
139134
let forked = Arc::new(Self {
140135
id: PID_COUNTER.fetch_add(1, Ordering::Acquire) as _,
141136
name: self.name.clone(),
142-
parent: Some(Arc::downgrade(&self)),
137+
parent: SpinMutex::new(Some(Arc::downgrade(&self))),
143138
threads: SpinMutex::new(Vec::new()),
144139
address_space: Arc::new(SpinMutex::new(self.address_space.lock().fork()?)),
145140
root_dir: SpinMutex::new(self.root_dir.lock().clone()),
@@ -215,7 +210,7 @@ impl Process {
215210
Ok(Self {
216211
id,
217212
name,
218-
parent: parent.map(|x| Arc::downgrade(&x)),
213+
parent: SpinMutex::new(parent.map(|x| Arc::downgrade(&x))),
219214
threads: SpinMutex::new(Vec::new()),
220215
address_space: Arc::new(SpinMutex::new(space)),
221216
status: SpinMutex::new(ProcessState::Running),

kernel/src/process/signal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ pub fn deliver_pending_signals(context: &mut Context) {
425425
match sig.default_action() {
426426
DefaultAction::Ignore | DefaultAction::Continue => continue,
427427
DefaultAction::Terminate | DefaultAction::CoreDump => {
428-
Process::exit(0x7f + sig.as_raw() as u8);
428+
Process::exit_signal(sig);
429429
}
430430
DefaultAction::Stop => {
431431
enter_stopped_state(&proc, sig);

0 commit comments

Comments
 (0)