lib/scripts/process
author nipkow
Fri May 30 18:13:40 2014 +0200 (2014-05-30)
changeset 57136 653e56c6c963
parent 39583 c1e9c6dfeff8
permissions -rwxr-xr-x
must not cancel common factors on both sides of (in)equations in linear arithmetic decicision procedure
     1 #!/usr/bin/env perl
     2 #
     3 # Author: Makarius
     4 #
     5 # exec process - with optional process group and report of pid
     6 #
     7 
     8 use warnings;
     9 use strict;
    10 
    11 # process group
    12 
    13 my $group = $ARGV[0]; shift(@ARGV);
    14 
    15 if ($group eq "group") {
    16   use POSIX "setsid";
    17   POSIX::setsid || die $!;
    18 }
    19 
    20 
    21 # report pid
    22 
    23 my $pid_name = $ARGV[0]; shift(@ARGV);
    24 
    25 if ($pid_name eq "-") {
    26   print "$$\n";
    27 }
    28 else {
    29   open (PID_FILE, ">", $pid_name) || die $!;
    30   print PID_FILE "$$";
    31   close PID_FILE;
    32 }
    33 
    34 
    35 # exec process
    36 
    37 my $script = $ARGV[0]; shift(@ARGV);
    38 
    39 if ($script eq "script") {
    40   my $cmd_line = $ARGV[0]; shift(@ARGV);
    41   exec $cmd_line || die $!;
    42 }
    43 else {
    44   (exec { $ARGV[0] } @ARGV) || die $!;
    45 }
    46