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