summaryrefslogtreecommitdiff
path: root/loadbars.pl
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2011-01-14 21:37:16 +0000
committerPaul Buetow <paul@buetow.org>2011-01-14 21:37:16 +0000
commit2908ae83e8d4d5a394df97ba4464d446e267411e (patch)
tree92f324477e8e27a26d6efb2caeb52be5733e54fd /loadbars.pl
parent1d0ddee438f89209a5dc88b49b26436600a9b5ad (diff)
all threads are exiting using function end
Diffstat (limited to 'loadbars.pl')
-rwxr-xr-xloadbars.pl13
1 files changed, 7 insertions, 6 deletions
diff --git a/loadbars.pl b/loadbars.pl
index cebce9e..28854c4 100755
--- a/loadbars.pl
+++ b/loadbars.pl
@@ -104,8 +104,6 @@ sub sum (@) {
return $sum;
}
-sub loop (&) { $_[0]->() while 1 }
-
sub parse_cpu_line ($) {
my ($name, %load);
@@ -118,9 +116,9 @@ sub parse_cpu_line ($) {
sub thr_get_stat ($) {
my $host = shift;
- my $sigusr1 = 0;
+ my ($sigusr1, $sigstop) = (0, 0);
- loop {
+ do {
my $bash = <<"BASH";
if [ -e /proc/stat ]; then
proc=/proc/stat
@@ -145,7 +143,7 @@ BASH
say "Shutting down get_stat($host) & PID $pid";
kill 1, $pid;
close $pipe;
- threads->exit();
+ $sigstop = 1;
};
# Toggle CPUs
@@ -166,8 +164,11 @@ BASH
$cpuregexp = qr/$CONF{cpuregexp}/;
$sigusr1 = 0;
}
+
+ last if $sigstop;
}
- }
+
+ } until $sigstop;
}
sub get_rect ($$) {