sub button_callback{ use Proc::ProcessTable; # prevent button from working on second click $start_button->configure(-state => 'disabled'); #run your program so it can get its pid , read perldoc perlipc my $pid = open(TH, "my_program |"); # start a timer to check for the $pid my $timer; #declare first so it can be cancelled in its own callback $timer = $mw->repeat(1000, sub{ # you can grep a shell and grep thru the output of ps, or my $t = new Proc::ProcessTable; foreach my $p (@{$t->table}){ if( $p->pid == $pid){ print "still running\n"; }else{ #renable button $start_button->configure(-state => 'normal'); } #cancel the timer $timer->cancel; }); }