>> Here is an example. Suppose you wanted to kill all existing
>> processes of the current program:
>>
>>   pidList = `ps -C #{File.basename $0} -o pid`.split.map! {|s| s.to_i}
>>   pidList.shift # discard header
>>   pidList.reject! {|pid| pid == $$}
>>
>>   pidList.each do |pid|
>>     Process.kill :SIGTERM, pid
>>   end
>
> Here's a better way to write the above:
>
>  pidList = `ps -C #{File.basename $0} -o pid`.
>    split[1..-1]. # discard header from `ps` output
>    map! {|s| s.to_i}.
>    reject! {|pid| pid == $$}
>
>  pidList.each do |pid|
>    Process.kill :SIGTERM, pid
>  end

Couldn't you take it all the way to this?

`ps -C #{File.basename $0} -o pid h`. # no header
   map! {|s| s.to_i}.
   reject! {|pid| pid == $$}.
   each {|pid| Process.kill :SIGTERM, pid}