#!/usr/pkg/bin/ruby18
#### prime-userdict-update: Command to update a userdict of PRIME.
#### $Id: prime-refresh.src,v 1.4 2005/03/07 07:51:34 komatsu Exp $
####
#### Copyright (C) 2003 Hiroyuki Komatsu <komatsu@taiyaki.org>
####     All rights reserved.
####     This is free software with ABSOLUTELY NO WARRANTY.
####
#### You can redistribute it and/or modify it under the terms of 
#### the GNU General Public License version 2.

PRIME_LIBDIR = '/usr/pkg/lib/ruby/vendor_ruby/1.8'
$LOAD_PATH.unshift(PRIME_LIBDIR) unless $LOAD_PATH.member?(PRIME_LIBDIR)

require 'prime/prime-config'

def main ()
  IO::popen('ps ax').readlines.each {|line|
    (pid, tty, stat, time, *command) = line.chomp.split(/ +/)
    if command[0] =~ /ruby/ and command[1] =~ /prime$/ then
      system('kill', '-HUP', pid)
    end
  }
end

if File::expand_path($0) == File::expand_path(__FILE__) then
  main()
end
