Guest User

Untitled

a guest
May 22nd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.60 KB | None | 0 0
  1. print "Forking child process... " unless $quiet;
  2. my $child = fork();
  3.  
  4. if (! defined $child) {
  5.   print STDERR "Failed to fork child process. Aborting.\n";
  6.   exit 1;
  7. } elsif ($child == 0) {
  8.   # child, suppress all output from exec cmd and reduce priority to minimum
  9.   open STDERR, '>/dev/null';
  10.   open STDOUT, '>/dev/null';
  11.   setpriority(0, 0, 20);
  12.   exec("<cmd to exec>");
  13.   exit 0;
  14. } else {
  15.   print "done.\nWaiting for output..." unless $quiet;
  16.  
  17.   my $sleeptick = 0;
  18.   while (! -e "<output file>") {
  19.     print '.';
  20.     $sleeptick += sleep 10;
  21.   }
  22.   print " output found.\n" unless $quiet;
  23. }
Add Comment
Please, Sign In to add comment