[ Thanks to Mike
Golvach for this link. ]
“In the first screenshot, we’ve isolated process id 499
(which happens to be the X server), since it’s the only process on
the box that meets the “CPU percentage” criteria. Once it finds
that process, it adds it to the default temporary file (the simple
way to maintain state ;). We then populate the /tmp/munchiestats
file with a whole bunch of other PID’s (some real, some
non-existent) and multiple instances of PID 499 (but, less than 9,
so we don’t trigger the kill on the next execution) and cat that so
you can see the contents:“In the second screenshot, we run munchies again and see it
clear all the PID’s in the temp file that are legitimate, but
aren’t using over 10% of the CPU anymore. We also free any PID’s in
the temp file that don’t exist any more (possibly, from a process
exiting, but – in this case – because we just made them up ;). The
final run executes the kill of PID 499 and removes it from the temp
file:”