lib/scripts/bash
changeset 35023 16f9877abf0b
parent 34197 aecdcaaa8ff3
child 35024 0faeabd99289
equal deleted inserted replaced
35022:c844b93dd147 35023:16f9877abf0b
       
     1 #!/usr/bin/env perl
       
     2 #
       
     3 # Author: Makarius
       
     4 #
       
     5 # bash - invoke shell command line (with robust signal handling)
       
     6 #
       
     7 
       
     8 use warnings;
       
     9 use strict;
       
    10 
       
    11 
       
    12 # args
       
    13 
       
    14 my ($group, $script_name, $pid_name, $output_name) = @ARGV;
       
    15 
       
    16 
       
    17 # process id
       
    18 
       
    19 if ($group eq "group") {
       
    20   use POSIX "setsid";
       
    21   POSIX::setsid || die $!;
       
    22 }
       
    23 
       
    24 open (PID_FILE, ">", $pid_name) || die $!;
       
    25 print PID_FILE "$$";
       
    26 close PID_FILE;
       
    27 
       
    28 
       
    29 # exec script
       
    30 
       
    31 $SIG{'INT'} = "DEFAULT";   #paranoia setting, required for Cygwin
       
    32 exec qq/exec bash '$script_name' > '$output_name'/;