brendano (owner)

Revisions

gist: 5395 Download_button fork
public
Description:
pskill
Public Clone URL: git://gist.github.com/5395.git
pskill
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env ruby
# USAGE: ps wwaux | grep badprocess | pskill
# Like awk '{print $2}' | xargs kill, except somewhat smarter
 
class Array
  def map_if(&b)
    map(&b).select{|x| x}
  end
end
 
procs = STDIN.readlines.map_if{|l| l !~ /grep/ && l.split[1]}
if procs.empty?
  puts "no processes"
  exit
end
 
# puts "killing #{procs.join(" ")}"
cmd = "kill #{ARGV} #{procs.join(" ")}"
puts cmd
system cmd