From 1652dd263dc318b27da384609b7d111f495dd382 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Sun, 23 Mar 2008 14:29:41 +0000 Subject: * added sigtrap protection (against user pressing CTRL-C, for instance) and made sure that any pending cleanup functions are invoked upon unload of module * some formatting corrections git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1676 95ad53e4-c205-0410-b2fa-d234c58c8868 --- lib/OpenSLX/Basics.pm | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'lib/OpenSLX/Basics.pm') diff --git a/lib/OpenSLX/Basics.pm b/lib/OpenSLX/Basics.pm index fab5554a..230bf72b 100644 --- a/lib/OpenSLX/Basics.pm +++ b/lib/OpenSLX/Basics.pm @@ -35,6 +35,7 @@ $VERSION = 1.01; our (%openslxConfig, %cmdlineConfig, %openslxPath); +use sigtrap qw( die normal-signals error-signals ); use subs qw(die warn); use open ':utf8'; @@ -42,7 +43,7 @@ use open ':utf8'; ################################################################################ ### Module implementation ################################################################################ -require Carp; # do not import anything as we are going to overload carp +require Carp; # do not import anything as we are going to overload carp # and croak! use Carp::Heavy; # use it here to have it loaded immediately, not at # the time when carp() is being invoked (which might @@ -166,13 +167,15 @@ sub openslxInit GetOptions(%openslxCmdlineArgs); # try to read and evaluate config files: - my $configPath = $cmdlineConfig{'config-path'} - || $openslxConfig{'config-path'}; + my $configPath + = $cmdlineConfig{'config-path'} || $openslxConfig{'config-path'}; my $sharePath = "$openslxConfig{'base-path'}/share"; my $verboseLevel = $cmdlineConfig{'verbose-level'} || 0; - foreach my $f ("$sharePath/settings.default", "$configPath/settings", - "$ENV{HOME}/.openslx/settings") - { + foreach my $f ( + "$sharePath/settings.default", + "$configPath/settings", + "$ENV{HOME}/.openslx/settings" + ) { next unless -e $f; if ($verboseLevel >= 2) { vlog(0, "reading config-file $f..."); @@ -207,12 +210,12 @@ sub openslxInit if (defined $openslxConfig{'logfile'}) { open($openslxLog, '>>', $openslxConfig{'logfile'}) - or croak( - _tr( - "unable to append to logfile '%s'! (%s)", - $openslxConfig{'logfile'}, $! - ) - ); + or croak( + _tr( + "unable to append to logfile '%s'! (%s)", + $openslxConfig{'logfile'}, $! + ) + ); } if ($openslxConfig{'verbose-level'} >= 2) { foreach my $key (sort keys %openslxConfig) { @@ -633,4 +636,10 @@ sub instantiateClass return $class->new; } +# ------------------------------------------------------------------------------ +END +{ + invokeCleanupFunctions() if %cleanupFunctions; +} + 1; -- cgit v1.2.3-55-g7522