my $t1; sub runbutton{ $bar->g_grid(); $bar->start(); $t1 = threads->create(sub { local $SIG{'KILL'} = sub { threads->exit }; system("timer.bat"); }); $t1->set_thread_exit_only(1); my $start = time; my $end = time; while ($t1->is_running()) { $end = time(); $mytext = sprintf("%.2f\n", $end - $start); Tkx::update(); } $bar->stop(); $bar->g_grid_forget(); $b4->g_grid_forget(); } sub cancelbutton { $t1->kill('KILL')->detach(); }