ssoper (owner)

Revisions

  • df8a3d ssoper Tue Oct 27 17:34:09 -0700 2009
gist: 220112 Download_button fork
public
Public Clone URL: git://gist.github.com/220112.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Using ruby to cleanup any pesky X instances
 
require 'fileutils'
 
Dir.glob('/tmp/xvfb-run.*').each do |entry|
  pid = entry[/\d{3,5}$/].to_i rescue nil
  next unless pid
  Process.kill("TERM", pid) rescue Errno::ESRCH
  FileUtils.rm_rf(entry)
end
 
Dir.glob('/tmp/.X*-lock').each do |entry|
  pid = IO.read(entry).to_i rescue nil
  next unless pid
  Process.kill("TERM", pid) rescue Errno::ESRCH
  FileUtils.rm_rf(entry)
end