Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print "Forking child process... " unless $quiet;
- my $child = fork();
- if (! defined $child) {
- print STDERR "Failed to fork child process. Aborting.\n";
- exit 1;
- } elsif ($child == 0) {
- # child, suppress all output from exec cmd and reduce priority to minimum
- open STDERR, '>/dev/null';
- open STDOUT, '>/dev/null';
- setpriority(0, 0, 20);
- exec("<cmd to exec>");
- exit 0;
- } else {
- print "done.\nWaiting for output..." unless $quiet;
- my $sleeptick = 0;
- while (! -e "<output file>") {
- print '.';
- $sleeptick += sleep 10;
- }
- print " output found.\n" unless $quiet;
- }
Add Comment
Please, Sign In to add comment