mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-24 01:43:22 +00:00
Check file_table in PID directory before access
This commit is contained in:
@ -27,7 +27,7 @@ impl FdDirOps {
|
||||
.parent(parent)
|
||||
.build()
|
||||
.unwrap();
|
||||
// Guard against the race condition when procfs is being accessed for an exiting process,
|
||||
// This is for an exiting process that has not yet been reaped by its parent,
|
||||
// whose file table may have already been released.
|
||||
if let Some(file_table_ref) = file_table.lock().as_ref() {
|
||||
file_table_ref
|
||||
|
@ -36,12 +36,13 @@ impl PidDirOps {
|
||||
.volatile()
|
||||
.build()
|
||||
.unwrap();
|
||||
file_table
|
||||
.lock()
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.read()
|
||||
.register_observer(Arc::downgrade(&pid_inode) as _);
|
||||
// This is for an exiting process that has not yet been reaped by its parent,
|
||||
// whose file table may have already been released.
|
||||
if let Some(file_table_ref) = file_table.lock().as_ref() {
|
||||
file_table_ref
|
||||
.read()
|
||||
.register_observer(Arc::downgrade(&pid_inode) as _);
|
||||
}
|
||||
|
||||
pid_inode
|
||||
}
|
||||
|
Reference in New Issue
Block a user