File tree Expand file tree Collapse file tree 1 file changed +14
-17
lines changed
Expand file tree Collapse file tree 1 file changed +14
-17
lines changed Original file line number Diff line number Diff line change @@ -250,23 +250,20 @@ fn command(pid: u32) -> String {
250250 let result: String = trimmed. into ( ) ;
251251
252252 if cfg ! ( target_os = "linux" ) && result. is_empty ( ) {
253- {
254- match PathBuf :: from_str ( & format ! ( "/proc/{pid}/status" ) ) {
255- Ok ( path) => {
256- let file = File :: open ( path) . unwrap ( ) ;
257- let content = read_to_string ( file) . unwrap ( ) ;
258- let line = content
259- . lines ( )
260- . collect :: < Vec < _ > > ( )
261- . first ( )
262- . unwrap ( )
263- . split ( ':' )
264- . collect :: < Vec < _ > > ( ) ;
265-
266- line[ 1 ] . trim ( ) . to_owned ( )
267- }
268- Err ( _) => String :: new ( ) ,
269- }
253+ let path = PathBuf :: from_str ( & format ! ( "/proc/{pid}/status" ) ) . unwrap ( ) ;
254+ if let Ok ( file) = File :: open ( path) {
255+ let content = read_to_string ( file) . unwrap ( ) ;
256+ let line = content
257+ . lines ( )
258+ . collect :: < Vec < _ > > ( )
259+ . first ( )
260+ . unwrap ( )
261+ . split ( ':' )
262+ . collect :: < Vec < _ > > ( ) ;
263+
264+ line[ 1 ] . trim ( ) . to_owned ( )
265+ } else {
266+ String :: new ( )
270267 }
271268 } else {
272269 result
You can’t perform that action at this time.
0 commit comments