J
joergwenzel
Hi,
who can help me, to kill the threads in this script.
I create lot of thread with a tar. If the tar canceled with errors, i
have to kill the rest of
the threads with tar. I dont now what is the best way. I tested with
kill Hup, but doesn't work.
code:
..
# fill my array with
.....
my $cmd =
"GZIP=$gzip; $tar -C $startdir -X $tapedir/exclude -czf
$tapedir/$dname"
. ".tar.gz . ";
push( @restore, "$tar -C (Please set path here!) -xzvf
$dname.tar.gz" );
push( @todo, $cmd ); # push Task on TODO
....
..
while ( $#todo >= 0 && $result == 0) {
last if($result > 0);
my $cmd = pop(@todo) ;
$sem->down(); # only n threads on the same time
if ( $result == 0) {
my $thread = threads->new(
\&Task,
$cmd, # create a new thread
);
$thread->detach();
}
....
..
#-------------------------------------------------------------------------
sub Task {
my (
$cmd, # Parameter
) = @_;
my $id = threads->self->tid;
$thread_run++;
my $result += system ($cmd)/256;;
if ($debug == 1) { print " Return: $result \n\n"; }
$sem->up();
#$thread_run--;
printf "Thread %02d: fertig.\n", $id;
kill ("HUP", -$$);
if ($result >0){print "\n\n Fehler !!!!!!!!\n\n";
kill ("HUP", -$$);
}
}
who can help me, to kill the threads in this script.
I create lot of thread with a tar. If the tar canceled with errors, i
have to kill the rest of
the threads with tar. I dont now what is the best way. I tested with
kill Hup, but doesn't work.
code:
..
# fill my array with
.....
my $cmd =
"GZIP=$gzip; $tar -C $startdir -X $tapedir/exclude -czf
$tapedir/$dname"
. ".tar.gz . ";
push( @restore, "$tar -C (Please set path here!) -xzvf
$dname.tar.gz" );
push( @todo, $cmd ); # push Task on TODO
....
..
while ( $#todo >= 0 && $result == 0) {
last if($result > 0);
my $cmd = pop(@todo) ;
$sem->down(); # only n threads on the same time
if ( $result == 0) {
my $thread = threads->new(
\&Task,
$cmd, # create a new thread
);
$thread->detach();
}
....
..
#-------------------------------------------------------------------------
sub Task {
my (
$cmd, # Parameter
) = @_;
my $id = threads->self->tid;
$thread_run++;
my $result += system ($cmd)/256;;
if ($debug == 1) { print " Return: $result \n\n"; }
$sem->up();
#$thread_run--;
printf "Thread %02d: fertig.\n", $id;
kill ("HUP", -$$);
if ($result >0){print "\n\n Fehler !!!!!!!!\n\n";
kill ("HUP", -$$);
}
}