#!/usr/bin/perl -w use strict; use POSIX; # incomplete example, tailor to you needs $| = 1; my $pid = fork; my $result; if ($pid) { my $kid; print "Please Wait...
\n"; do { sleep 2; print "\0"; $kid = waitpid(-1, &WNOHANG); if ($kid > 0) { $result = $? >> 8; } } until ($kid == -1); } else { if (defined $pid) { exec("./long_running_prog"); CORE::exit 1; } else { print "Failed to fork!
"; $result = 1; } } if (not $result) { print "Run successful
\n"; } else { print "Run Failed. Error($result)
\n"; }