lib/scripts/system.pl
author wenzelm
Mon Feb 18 21:33:29 2008 +0100 (2008-02-18)
changeset 26092 260cca2e16fa
child 26096 783f957dcb01
permissions -rw-r--r--
system.pl - invoke shell command line (with robust signal handling);
wenzelm@26092
     1
#
wenzelm@26092
     2
# $Id$
wenzelm@26092
     3
# Author: Makarius
wenzelm@26092
     4
#
wenzelm@26092
     5
# system.pl - invoke shell command line (with robust signal handling)
wenzelm@26092
     6
#
wenzelm@26092
     7
wenzelm@26092
     8
# args
wenzelm@26092
     9
wenzelm@26092
    10
($group, $script_name, $pid_name, $output_name) = @ARGV;
wenzelm@26092
    11
wenzelm@26092
    12
wenzelm@26092
    13
# process id
wenzelm@26092
    14
wenzelm@26092
    15
if ($group eq "group") { setpgrp; }
wenzelm@26092
    16
wenzelm@26092
    17
open (PID_FILE, ">", $pid_name) || die $!;
wenzelm@26092
    18
print PID_FILE "$$\n";
wenzelm@26092
    19
close PID_FILE;
wenzelm@26092
    20
wenzelm@26092
    21
wenzelm@26092
    22
# exec script
wenzelm@26092
    23
wenzelm@26092
    24
$SIG{'INT'} = "DEFAULT";   #paranoia setting, required for Cygwin
wenzelm@26092
    25
exec qq/exec bash '$script_name' > '$output_name'/;
wenzelm@26092
    26