From 9562c5d46175f75515afff8b1005a12002b231e8 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Fri, 22 Feb 2002 10:42:31 +0000 Subject: even smarted process to kill selection --- perl-install/pkgs.pm | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'perl-install/pkgs.pm') diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm index 820f888a1..77d0492f4 100644 --- a/perl-install/pkgs.pm +++ b/perl-install/pkgs.pm @@ -1478,7 +1478,17 @@ sub install($$$;$$) { close OUTPUT; #- now search for child process which may be locking the cdrom, making it unable to be ejected. - if (my @killpid = difference2([ grep { /^\d+$/ } all("/proc") ], \@prev_pids)) { + my @allpids = grep { /^\d+$/ } all("/proc"); + my %ppids; + foreach (@allpids) { + cat_("/proc/$_/status") =~ /^PPid:\s+(\d+)/m; + push @{$ppids{$1 || 1}}, $_; + } + my @killpid = difference2(\@allpids, [ @prev_pids, + difference2([ $$, hashtree2list(getppid, \%ppids) ], + [ hashtree2list($$, \%ppids) ]) ]); + + if (@killpid) { log::l("ERROR: DrakX should not have to clean the packages shit. Killing ". join(", ", @killpid)); kill 15, @killpid; sleep 2; @@ -1678,4 +1688,16 @@ ypserv } @naughtyServers; } +sub hashtree2list { + my ($e, $h) = @_; + my @l; + my @todo = $e; + while (@todo) { + my $e = shift @todo; + push @l, $e; + push @todo, @{$h->{$e}}; + } + @l; +} + 1; -- cgit v1.2.1