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)
|
.parent(parent)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.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.
|
// whose file table may have already been released.
|
||||||
if let Some(file_table_ref) = file_table.lock().as_ref() {
|
if let Some(file_table_ref) = file_table.lock().as_ref() {
|
||||||
file_table_ref
|
file_table_ref
|
||||||
|
@ -36,12 +36,13 @@ impl PidDirOps {
|
|||||||
.volatile()
|
.volatile()
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
file_table
|
// This is for an exiting process that has not yet been reaped by its parent,
|
||||||
.lock()
|
// whose file table may have already been released.
|
||||||
.as_ref()
|
if let Some(file_table_ref) = file_table.lock().as_ref() {
|
||||||
.unwrap()
|
file_table_ref
|
||||||
.read()
|
.read()
|
||||||
.register_observer(Arc::downgrade(&pid_inode) as _);
|
.register_observer(Arc::downgrade(&pid_inode) as _);
|
||||||
|
}
|
||||||
|
|
||||||
pid_inode
|
pid_inode
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user