File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,12 @@ fn collect_matched_pids(settings: &Settings) -> Vec<ProcessInformation> {
168168 let filtered: Vec < ProcessInformation > = {
169169 let mut tmp_vec = Vec :: new ( ) ;
170170
171+ let our_pid = std:: process:: id ( ) as usize ;
171172 for mut pid in walk_process ( ) . collect :: < Vec < _ > > ( ) {
173+ if pid. pid == our_pid {
174+ continue ;
175+ }
176+
172177 let run_state_matched = match ( & settings. runstates , pid. run_state ( ) ) {
173178 ( Some ( arg_run_states) , Ok ( pid_state) ) => {
174179 arg_run_states. contains ( & pid_state. to_string ( ) )
Original file line number Diff line number Diff line change @@ -420,3 +420,15 @@ fn test_current_user() {
420420 . arg ( uucore:: process:: getuid ( ) . to_string ( ) )
421421 . succeeds ( ) ;
422422}
423+
424+ #[ test]
425+ #[ cfg( target_os = "linux" ) ]
426+ fn test_does_not_match_current_process ( ) {
427+ let our_pid = std:: process:: id ( ) ;
428+ dbg ! ( & our_pid) ;
429+ new_ucmd ! ( )
430+ . arg ( "-f" )
431+ . arg ( "UNIQUE_STRING_THAT_DOES_NOT_MATCH_ANY_OTHER_PROCESS" )
432+ . fails ( )
433+ . no_output ( ) ;
434+ }
You can’t perform that action at this time.
0 commit comments