lib/scripts/process
changeset 39583 c1e9c6dfeff8
parent 39581 430ff865089b
equal deleted inserted replaced
39582:a873158542d0 39583:c1e9c6dfeff8
     6 #
     6 #
     7 
     7 
     8 use warnings;
     8 use warnings;
     9 use strict;
     9 use strict;
    10 
    10 
    11 # args
    11 # process group
    12 
    12 
    13 my ($group, $pid_name, $cmd_line) = @ARGV;
    13 my $group = $ARGV[0]; shift(@ARGV);
    14 
       
    15 
       
    16 # process group
       
    17 
    14 
    18 if ($group eq "group") {
    15 if ($group eq "group") {
    19   use POSIX "setsid";
    16   use POSIX "setsid";
    20   POSIX::setsid || die $!;
    17   POSIX::setsid || die $!;
    21 }
    18 }
    22 
    19 
    23 
    20 
    24 # pid
    21 # report pid
       
    22 
       
    23 my $pid_name = $ARGV[0]; shift(@ARGV);
    25 
    24 
    26 if ($pid_name eq "-") {
    25 if ($pid_name eq "-") {
    27   print "$$\n";
    26   print "$$\n";
    28 }
    27 }
    29 else {
    28 else {
    33 }
    32 }
    34 
    33 
    35 
    34 
    36 # exec process
    35 # exec process
    37 
    36 
    38 exec $cmd_line;
    37 my $script = $ARGV[0]; shift(@ARGV);
    39 
    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