Check file_table before use

This commit is contained in:
Marsman1996
2025-06-18 16:28:58 +08:00
committed by Tate, Hongliang Tian
parent 00e6905d93
commit 2f097ab8f8

View File

@ -27,12 +27,13 @@ impl FdDirOps {
.parent(parent) .parent(parent)
.build() .build()
.unwrap(); .unwrap();
file_table // Guard against the race condition when procfs is being accessed for an exiting process,
.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(&fd_inode) as _); .register_observer(Arc::downgrade(&fd_inode) as _);
}
fd_inode fd_inode
} }