]> granicus.if.org Git - psmisc/commitdiff
killall - Fix race condition for --older-than and --younger-than
authorJohn Ferlito <johnf@inodes.org>
Sat, 1 Apr 2017 23:20:33 +0000 (09:20 +1000)
committerJohn Ferlito <johnf@inodes.org>
Sat, 1 Apr 2017 23:20:33 +0000 (09:20 +1000)
If killall runs really quickly then it' possible for process_age to be
0.0. The existing logic will then always kill the process due t
"&& process_age" always being false in that case.

src/killall.c

index a2fcabdb6df4873cbcdee3988be525e1014b946f..1826362d8d488f7d2e2a79a84d532a33d43d1857 100644 (file)
@@ -518,9 +518,9 @@ kill_all (int signal, int name_count, char **namelist, struct passwd *pwent)
            continue;
 
        /* test for process age, if required */
-       if ( younger_than && process_age_sec && (process_age_sec > younger_than ) )
+       if ( younger_than && (process_age_sec > younger_than ) )
            continue;
-       if ( older_than   && process_age_sec && (process_age_sec < older_than ) )
+       if ( older_than   && (process_age_sec < older_than ) )
            continue;
 
         got_long = 0;