aboutsummaryrefslogtreecommitdiffstats
path: root/iurt
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mageia.org>2018-10-15 16:06:11 +0000
committerPascal Terjan <pterjan@mageia.org>2018-10-15 16:30:46 +0000
commit6e3fcbda2b0bc613ebd46fda8b5b92cf7a6b2f5a (patch)
tree6e8bd5a95b690ab9de69b7d1fc55266644e3aa62 /iurt
parent1eb80e1355efab11a8d93f237b22aea50720ca8e (diff)
downloadiurt-6e3fcbda2b0bc613ebd46fda8b5b92cf7a6b2f5a.tar
iurt-6e3fcbda2b0bc613ebd46fda8b5b92cf7a6b2f5a.tar.gz
iurt-6e3fcbda2b0bc613ebd46fda8b5b92cf7a6b2f5a.tar.bz2
iurt-6e3fcbda2b0bc613ebd46fda8b5b92cf7a6b2f5a.tar.xz
iurt-6e3fcbda2b0bc613ebd46fda8b5b92cf7a6b2f5a.zip
Use SIGTERM to kill iurt and install a handler
Diffstat (limited to 'iurt')
-rwxr-xr-xiurt17
1 files changed, 11 insertions, 6 deletions
diff --git a/iurt b/iurt
index 7dd57f8..0a24ded 100755
--- a/iurt
+++ b/iurt
@@ -71,13 +71,10 @@ sub bug_handler {
#exit(1);
}
+my ($chroot_name, $chroot_tmp, $chroot, $chroot_ref);
+
$SIG{SEGV} = sub { bug_handler(@_, 1) };
#$SIG{__DIE__} = \&bug_handler;
-$SIG{TERM} = sub {
- warn "Got KILLED by SIGTERM at " . strftime("%c", localtime()) . " .\n";
- exit(1);
-};
-
my $program_name = 'iurt';
# sessing parameters
@@ -516,6 +513,15 @@ if (!$config->{repository}) {
die "FATAL $program_name: no repository have been defined (use --repository to specify one on the command line";
}
+$SIG{TERM} = sub {
+ warn "Got KILLED by SIGTERM at " . strftime("%c", localtime()) . " .\n";
+ if (!$run{use_old_chroot} && $chroot_tmp) {
+ print "Cleaning up before dying.\n";
+ clean_chroot($chroot_tmp, \%run, $config);
+ }
+ exit(1);
+};
+
my $urpmi = Iurt::Urpmi->new(run => \%run, config => $config, urpmi_options => "-v --no-verify-rpm --tune-rpm=all --nolock --auto --no-recommends --ignoresize $config->{urpmi_options}");
$run{urpmi} = $urpmi;
@@ -612,7 +618,6 @@ $run{done} = \%done;
my $home = $config->{local_home};
my $chroot_base = $config->{chroot_base};
-my ($chroot_name, $chroot_tmp, $chroot, $chroot_ref);
$chroot_name = "chroot_$run{distro_tag}$debug_tag.$run{my_arch}";
if (!$run{use_old_chroot}) {
$chroot_tmp = "$chroot_base/chroot_tmp";