summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2001-03-07 13:55:56 +0000
committerFrancois Pons <fpons@mandriva.com>2001-03-07 13:55:56 +0000
commit5b7c8e3c88d8a924517263724f8680ba925f369a (patch)
tree80191202f4bf091074179b74b6af1a8bd73b49cc
parent414d8c6ac9d04a44f0de3cc6ebd937f85337b7b7 (diff)
downloaddrakx-5b7c8e3c88d8a924517263724f8680ba925f369a.tar
drakx-5b7c8e3c88d8a924517263724f8680ba925f369a.tar.gz
drakx-5b7c8e3c88d8a924517263724f8680ba925f369a.tar.bz2
drakx-5b7c8e3c88d8a924517263724f8680ba925f369a.tar.xz
drakx-5b7c8e3c88d8a924517263724f8680ba925f369a.zip
added support for killing all child process of a transaction, necessary to be
able to umount cdrom and eject it correctly.
-rw-r--r--perl-install/pkgs.pm28
1 files changed, 28 insertions, 0 deletions
diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm
index 6545ce9ee..a3b070419 100644
--- a/perl-install/pkgs.pm
+++ b/perl-install/pkgs.pm
@@ -1289,6 +1289,34 @@ sub install($$$;$$) {
log::l("rpm database closed");
close OUTPUT;
+
+ #- now search for child process which may be locking the cdrom, making it unable to be ejected.
+ my (@killpid, %tree, $pid);
+ local (*DIR, *F, $_);
+ opendir DIR, "/proc";
+ while ($pid = readdir DIR) {
+ $pid =~ /^\d+$/ or next;
+ open F, "/proc/$pid/status";
+ while (<F>) {
+ /^Pid:\s+(\d+)/ and $pid == $1 || die "incorrect pid reported for $pid (found $1)";
+ if (/^PPid:\s+(\d+)/) {
+ $tree{$pid} and die "PPID already found for $pid, previously $tree{$pid}, now $1";
+ $tree{$pid} = $1;
+ }
+ }
+ close F;
+ }
+ closedir DIR;
+ foreach (keys %tree) {
+ $pid = $_; while ($pid = $tree{$pid}) { $pid == $$ and push @killpid, $_ }
+ }
+ if (@killpid) {
+ log::l("killing process ". join(", ", @killpid));
+ kill 15, @killpid;
+ sleep 2;
+ kill 9, @killpid;
+ }
+
c::_exit(0);
}