my $TIMEOUT = 30; my $proc; # This script is located in same dir as the calling script. my $bg_script = "bg_script.pl"; ......code..... ............... $proc = Proc::Background->new(Cava::Packager::GetScriptCommand( "$bg_script", [], $ARG1, "$ARG2", $ARG3)); my $PID = $proc->pid; my $start_time = $proc->start_time; my $alive = $proc->alive; while($alive ne 0) { # This Checks again if it's still running... $alive = $proc->alive; # This while loop will force Perl::Gtk2 to continue processing # GUI Events while Background process continues executing... while (Gtk2->events_pending) { Gtk2->main_iteration; } Gtk2::Gdk->flush; $timeout_current = time; #->Sets the current time (EPOCH) # Get the difference in time from the current time and the # start time, to check if we hit the TIMEOUT limit of 30 sec $timeout_diff = $timeout_current - $timeout_start; # If the time difference is >= the TIMEOUT limit of 30 sec, then # use 'last' to break out of the loop... if ($timeout_diff >= $TIMEOUT) { $timed_out = 1; last; } # Sleep for 1000 milliseconds usleep(1000); }