[Collab-qa-commits] r839 - qabuildstat/buildagent
goneri at alioth.debian.org
goneri at alioth.debian.org
Mon Apr 28 20:18:30 UTC 2008
Author: goneri
Date: 2008-04-28 20:18:29 +0000 (Mon, 28 Apr 2008)
New Revision: 839
Modified:
qabuildstat/buildagent/qabuildstat-buildagent
Log:
use my own function to kill the child process
Modified: qabuildstat/buildagent/qabuildstat-buildagent
===================================================================
--- qabuildstat/buildagent/qabuildstat-buildagent 2008-04-28 06:44:32 UTC (rev 838)
+++ qabuildstat/buildagent/qabuildstat-buildagent 2008-04-28 20:18:29 UTC (rev 839)
@@ -12,7 +12,6 @@
use HTTP::Request::Common;
use LWP::UserAgent;
use HTTP::Response;
-use Proc::ProcessTable;
use Config::IniFiles;
###########################################################################
@@ -66,43 +65,21 @@
$ENV{LC_ALL} = 'C';
$ENV{LANG} = 'C';
-# From Proc::Killall TODO package this
-#Copyright (c) 1998-2006 Daniel J. Urist. All rights reserved.
-#This package is free software; you can redistribute it and/or modify
-#it under the same terms as Perl itself.
-sub get_pids {
- my($procs, @kids) = @_;
- my @pids;
- foreach my $kid (@kids) {
- foreach my $proc (@$procs) {
- if ($proc->ppid == $kid) {
- my $pid = $proc->pid;
- push @pids, $pid, get_pids $procs, $pid;
- }
+sub killThemAll {
+ my ($mainpid, $signal) = @_;
+
+ foreach (`ps --no-headers --ppid $mainpid -o pid`) {
+ next unless /(\d+)/;
+ my $pid = $1;
+ killThemAll($pid);
+ kill ($pid, $signal);
+ print "kill ($pid, $signal)\n";
}
- }
- @pids;
}
-sub killfam {
-
- my($signal, @pids) = @_;
-
- my $pt = Proc::ProcessTable->new;
- my(@procs) = @{$pt->table};
- my(@kids) = get_pids \@procs, @pids;
- @pids = (@pids, @kids);
- print "pid to kill: ";
- print $_." " foreach (@pids);
- print "\n";
- kill $signal, @pids;
-
-} # end killfam
-
-
sub purge {
die "please create: `".$vardir unless -d $vardir;
# TODO check for running script in background
@@ -160,16 +137,8 @@
if ($exit||isMemFull()||isDiskFull($workplace)||isDiskFull($buildarea)||isDiskFull('/tmp')) {
if (%job&&($exit||isDiskFull($workplace)||isDiskFull($buildarea))) {
print "Emergency clean up\n";
- killfam (15, keys %job);
+ killThemAll($$, 9);
- foreach (1..10) {
- sleep (1);
- print ".";
- }
- print "\n";
-
- killfam (9, keys %job);
-
foreach (keys %job) {
waitpid($_, WNOHANG);
delete ($job{$_});
@@ -381,8 +350,7 @@
foreach (`$cmd`) {
$tarballdir = $1 if /dpkg-source:\sextracting\s\S+\sin\s(\S+)/;
}
- print "tarballdir: $threadworkplace; $tarballdir\n";
- if (!$tarballdir) {
+ if (!$tarballdir) {
system("rm -r $threadworkplace $threadbuildarea") unless $keeptmpdir;
return;
}
More information about the Collab-qa-commits
mailing list