wmiirc-rumai

git clone git://oldgit.suckless.org/wmiirc-rumai/
Log | Files | Refs | README | LICENSE

commit 93c3a9af3abf88dcc62cd300eebefb6fc48f8497
parent 7b5ede68be1ab93dede033686d0b3fa9dd795c1d
Author: Suraj N. Kurapati <sunaku@gmail.com>
Date:   Thu, 21 Sep 2006 01:48:40 -0700

[project @ a83a6d2e76e22ea29a01380317c01202769d5309]

[project @ 120]
revert to throwing life saver for StandardError exceptions

Diffstat:
HISTORY | 2--
wmiirc | 36+++++++++++++++++++++---------------
2 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/HISTORY b/HISTORY @@ -9,8 +9,6 @@ This is a history of major changes to {my wmii configuration}[http://people.ucsc * show_menu now returns *nil* if nothing was chosen. -* Reverted to silent logging & recovery from error... xmessage & terminal are annoying! - * Updated event loop for {wmii-3.1's /event overload bug fix}[http://wmii.de/pipermail/wmii/2006-September/002718.html]. * Added explicit termination of already running instances in *wmiirc* via Process.kill and `ps`, instead of using /event as a means of coordinating said task. diff --git a/wmiirc b/wmiirc @@ -20,33 +20,39 @@ require 'logger' -LOG = Logger.new(__FILE__ + '.log', 5) +# Provide a means by which the user can rescue themselves. +def throw_life_saver aError + system 'xterm &' + + IO.popen('xmessage -file -', 'w') do |f| + f.puts aError.inspect, aError.backtrace + end +end +LOG = Logger.new(__FILE__ + '.log', 5) +LOG.info "starting" + # terminate existing instances 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| - LOG.info "stopping instance #{pid}" + LOG.info "stopping loader #{pid}" Process.kill :SIGTERM, pid end +# load the configuration + begin + load File.join(File.dirname(__FILE__), 'wmiirc-config.rb') -LOG.info "starting" - -begin - load File.join(File.dirname(__FILE__), 'wmiirc-config.rb') - -rescue => e - LOG.error e + rescue => e + LOG.error e + throw_life_saver e - LOG.info "recovering from above error" - retry - -rescue Exception => e - LOG.fatal e -end + rescue Exception => e + LOG.fatal e + end LOG.info "stopping"