lib/scripts/bash
author blanchet
Wed, 08 Sep 2010 15:57:50 +0200
changeset 39222 decf607a5a67
parent 35024 0faeabd99289
permissions -rwxr-xr-x
remove "safe" (as suggested by Tobias) and added "arith" to "try"
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35023
16f9877abf0b modernized perl scripts: prefer standalone executables;
wenzelm
parents: 34197
diff changeset
     1
#!/usr/bin/env perl
26092
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
     2
#
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
     3
# Author: Makarius
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
     4
#
35023
16f9877abf0b modernized perl scripts: prefer standalone executables;
wenzelm
parents: 34197
diff changeset
     5
# bash - invoke shell command line (with robust signal handling)
26092
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
     6
#
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
     7
35023
16f9877abf0b modernized perl scripts: prefer standalone executables;
wenzelm
parents: 34197
diff changeset
     8
use warnings;
16f9877abf0b modernized perl scripts: prefer standalone executables;
wenzelm
parents: 34197
diff changeset
     9
use strict;
16f9877abf0b modernized perl scripts: prefer standalone executables;
wenzelm
parents: 34197
diff changeset
    10
16f9877abf0b modernized perl scripts: prefer standalone executables;
wenzelm
parents: 34197
diff changeset
    11
26092
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
    12
# args
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
    13
35023
16f9877abf0b modernized perl scripts: prefer standalone executables;
wenzelm
parents: 34197
diff changeset
    14
my ($group, $script_name, $pid_name, $output_name) = @ARGV;
26092
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
    15
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
    16
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
    17
# process id
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
    18
26096
783f957dcb01 replaced setpgrp by more elaborate setsid;
wenzelm
parents: 26092
diff changeset
    19
if ($group eq "group") {
783f957dcb01 replaced setpgrp by more elaborate setsid;
wenzelm
parents: 26092
diff changeset
    20
  use POSIX "setsid";
26107
4b5e5fc1d11f removed junk;
wenzelm
parents: 26096
diff changeset
    21
  POSIX::setsid || die $!;
26096
783f957dcb01 replaced setpgrp by more elaborate setsid;
wenzelm
parents: 26092
diff changeset
    22
}
26092
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
    23
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
    24
open (PID_FILE, ">", $pid_name) || die $!;
34197
aecdcaaa8ff3 pid without newline -- required for Scala version of system_out;
wenzelm
parents: 29145
diff changeset
    25
print PID_FILE "$$";
26092
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
    26
close PID_FILE;
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
    27
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
    28
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
    29
# exec script
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
    30
260cca2e16fa system.pl - invoke shell command line (with robust signal handling);
wenzelm
parents:
diff changeset
    31
exec qq/exec bash '$script_name' > '$output_name'/;