gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gcl-devel] Re: off the wall


From: Camm Maguire
Subject: [Gcl-devel] Re: off the wall
Date: 06 Jun 2006 08:49:23 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Greetings, and thanks!  My feeble understanding is that killing the
parent does the same for children in the same process group, or
session, or whatever :-).  Is this not the case with mini-proveall?

Take care,

Robert Boyer <address@hidden> writes:

> Very remotely possibly of relevance to your p-or stuff.
> 
> Very possibly absurdly obvious and a waste of your time.
> 
> Below is a Perl subroutine that has been in the back of my
> mind to send to you.
> 
> The following killpid Perl code may be of interest to you
> because of the way that it kills off a process's
> sub-processes.  I had never heard of the cool "pstree"
> before.  I don't understand it at all, but "it seems to
> work".
> 
>    sub killpid {
>        ($pid) = @_;
>        $_ = `/usr/bin/pstree -p $pid`;
>        @pids = /\((\d+)\)/g;
>        foreach $p (@pids) { print "killing", $p, "\n"; kill 9, $p;}
>        foreach $p (@pids) { waitpid $p, 0;}}
> 
> 
> Bob
> 
> -------------------------------------------------------------------------------
> 
> Some probably very irrelevant context:
> 
> I got this file from a grad student here named John Erikson,
> address@hidden
> 
> #!/usr/bin/perl
> use POSIX;
> %tests = (
> "01" => ":mini-proveall",       
> "02" => ":mini-proveall",);
> sub killpid {
>     ($pid) = @_;
>     $_ = `/usr/bin/pstree -p $pid`;
>     @pids = /\((\d+)\)/g;
>     foreach $p (@pids) { print "killing", $p, "\n"; kill 9, $p;}
>     foreach $p (@pids) { waitpid $p, 0;}}
> $num = $ARGV[0];
> $tname = "testa-$num";
> $timeout = 5; 
>     $pid = fork();
>     if(!$pid) {
>       $SIG{INT} = sub { print "SIGINT!\n"; };
>       open(IN, "|/usr/bin/time --output=./results/${tname}.tim /p/bin/xa > 
> ./results/${tname}.dat");
>       print IN "$tests{$num}\n"; 
>       close IN;
>       exit 0;}
>     $SIG{INT} = sub { $secs = $timeout; };
>     $secs = 0;
>     while(!waitpid($pid, WNOHANG) && $secs < $timeout) { sleep 1; $secs++;}
>     if($secs >= $timeout) {killpid $pid;}
>     close OUT;
> 
> 
> 

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

[Prev in Thread] Current Thread [Next in Thread]