html/exec_clean.pl


   1 # $Id: exec-clean.pl,v 1.6 2002/07/04 13:18:02 jylefort Exp $
   2 
   3 use Irssi 20020121.2020 ();
   4 $VERSION = "1.01";
   5 %IRSSI = (
   6 	  authors     => 'Jean-Yves Lefort',
   7 	  contact     => 'jylefort\@brutele.be, decadix on IRCNet',
   8 	  name        => 'exec-clean',
   9 	  description => 'Adds a setting to automatically terminate a process whose parent window has been closed',
  10 	  license     => 'BSD',
  11 	  url         => 'http://void.adminz.be/irssi.shtml',
  12 	  changed     => '$Date: 2002/07/04 13:18:02 $ ',
  13 );
  14 
  15 # /set's:
  16 #
  17 #	autokill_orphan_processes
  18 #
  19 #		guess :)
  20 #
  21 # changes:
  22 #
  23 #	2002-07-04	release 1.01
  24 #			* signal_add's uses a reference instead of a string
  25 #
  26 #	2002-04-25	release 1.00
  27 #			* increased version number
  28 #
  29 #	2002-01-28	initial release
  30 #
  31 # todo:
  32 #
  33 #	* kill the process using a better method (TERM -> sleep -> KILL etc)
  34 
  35 use strict;
  36 use Irssi::UI;
  37 
  38 sub window_destroyed {
  39   my ($window) = @_;
  40 
  41   foreach (Irssi::UI::processes()) {
  42     if ($_->{target_win}->{refnum} == $window->{refnum}
  43 	&& Irssi::settings_get_bool("autokill_orphan_processes")) {
  44       kill 15, $_->{pid};
  45       return;
  46     }
  47   }
  48 }
  49 
  50 Irssi::signal_add("window destroyed", \&window_destroyed);
  51 Irssi::settings_add_bool("misc", "autokill_orphan_processes", 1);