lib/scripts/bash
author wenzelm
Sun, 07 Feb 2010 20:21:38 +0100
changeset 35023 16f9877abf0b
parent 34197 lib/scripts/system.pl@aecdcaaa8ff3
child 35024 0faeabd99289
permissions -rwxr-xr-x
modernized perl scripts: prefer standalone executables; exec bash wrapper script directly -- avoid intermediate process;

#!/usr/bin/env perl
#
# Author: Makarius
#
# bash - invoke shell command line (with robust signal handling)
#

use warnings;
use strict;


# args

my ($group, $script_name, $pid_name, $output_name) = @ARGV;


# process id

if ($group eq "group") {
  use POSIX "setsid";
  POSIX::setsid || die $!;
}

open (PID_FILE, ">", $pid_name) || die $!;
print PID_FILE "$$";
close PID_FILE;


# exec script

$SIG{'INT'} = "DEFAULT";   #paranoia setting, required for Cygwin
exec qq/exec bash '$script_name' > '$output_name'/;