my $TIMEOUT = 30; my $proc; my $bg_script = "./bg_script.pl"; $proc = Proc::Background->new("perl $bg_script $ARG1 \"$ARG2\" $ARG3 $ARG4"); my $PID = $proc->pid; my $start_time = $proc->start_time; my $alive = $proc->alive; my $timeout_start = time; my $timeout_current; my $timeout_diff; while($alive ne 0) { $alive = $proc->alive; # This will continue the processing of Gtk Events... while (Gtk2->events_pending) { Gtk2->main_iteration; } Gtk2::Gdk->flush; $timeout_current = time; $timeout_diff = $timeout_current - $timeout_start; if ($timeout_diff >= $TIMEOUT) { last; #->Use 'last' to break out of loop if we timed-out... } # Sleep for 1000 milliseconds usleep(1000); }