summaryrefslogtreecommitdiff
path: root/loadbars.pl
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2011-01-14 21:33:06 +0000
committerPaul Buetow <paul@buetow.org>2011-01-14 21:33:06 +0000
commit1d0ddee438f89209a5dc88b49b26436600a9b5ad (patch)
tree5eed191192d48500cd068327185a5495d7c82b19 /loadbars.pl
parentfaabd703545e41350574ca0a41500d403540776f (diff)
fixed segfault on quit bug
Diffstat (limited to 'loadbars.pl')
-rwxr-xr-xloadbars.pl52
1 files changed, 27 insertions, 25 deletions
diff --git a/loadbars.pl b/loadbars.pl
index b9f16cf..cebce9e 100755
--- a/loadbars.pl
+++ b/loadbars.pl
@@ -297,8 +297,13 @@ sub graph_stats ($) {
my $display_txt = $CONF{toggletxt};
my $display_summary = $CONF{togglesummary};
my $recv_msg = 0;
+ my $sigstop = 0;
+
+ $SIG{STOP} = sub {
+ say "Shutting down display_stats";
+ $sigstop = 1;
+ };
- # Toggle CPUs
$SIG{USR1} = sub { wait_for_stats };
# Set new window dimensions
@@ -320,7 +325,7 @@ sub graph_stats ($) {
my ($t1, $t2) = (Time::HiRes::time(), undef);
- loop {
+ do {
my ($x, $y) = (0, 0);
my $factor = $CONF{factor};
@@ -407,7 +412,8 @@ TIMEKEEPER:
draw_background $app, $rects;
$recv_msg = 0;
}
- };
+
+ } until $sigstop;
return undef;
}
@@ -422,11 +428,6 @@ sub thr_display_stats () {
-resizeable => 0,
);
- $SIG{STOP} = sub {
- say "Shutting down display_stats";
- threads->exit();
- };
-
graph_stats $app
}
@@ -438,23 +439,6 @@ sub send_message ($$) {
$thread->kill('USR2');
}
-sub create_threads (\@) {
- my ($hosts) = @_;
-
- my @threads;
- push @threads, threads->create('thr_get_stat', $_) for @$hosts;
-
- return (threads->create('thr_display_stats'), @threads);
-}
-
-sub stop_threads (@) {
- for (@_) {
- $_->kill('STOP');
- $_->join();
- }
-
- return undef;
-}
sub set_togglecpu_regexp () {
$CONF{cpuregexp} = $CONF{togglecpu} ? 'cpu ' : 'cpu';
@@ -650,6 +634,24 @@ END
return (\$hosts, $closure);
}
+sub create_threads (\@) {
+ my ($hosts) = @_;
+
+ my @threads;
+ push @threads, threads->create('thr_get_stat', $_) for @$hosts;
+
+ return (threads->create('thr_display_stats'), @threads);
+}
+
+sub stop_threads (@) {
+ for (@_) {
+ $_->kill('STOP');
+ $_->join();
+ }
+
+ return undef;
+}
+
sub main () {
my ($hosts, $dispatch) = dispatch_table;
my $help;