File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -481,6 +481,20 @@ fn update_proc_info(
481481 // Do not use cmd[0] because it is not the same thing.
482482 // See https://github.com/GuillaumeGomez/sysinfo/issues/697.
483483 p. exe = realpath ( proc_path. replace_and_join ( "exe" ) ) ;
484+ // If the target executable file was modified or removed, linux appends ` (deleted)` at
485+ // the end. We need to remove it.
486+ // See https://github.com/GuillaumeGomez/sysinfo/issues/1585.
487+ let deleted = b" (deleted)" ;
488+ if let Some ( exe) = & mut p. exe
489+ && let Some ( file_name) = exe. file_name ( )
490+ && file_name. as_encoded_bytes ( ) . ends_with ( deleted)
491+ {
492+ let mut file_name = file_name. as_encoded_bytes ( ) . to_vec ( ) ;
493+ file_name. truncate ( file_name. len ( ) - deleted. len ( ) ) ;
494+ unsafe {
495+ exe. set_file_name ( OsString :: from_encoded_bytes_unchecked ( file_name) ) ;
496+ }
497+ }
484498 }
485499
486500 if refresh_kind. cmd ( ) . needs_update ( || p. cmd . is_empty ( ) ) {
You can’t perform that action at this time.
0 commit comments