| author | wenzelm |
| Sun, 08 Aug 2010 20:03:31 +0200 | |
| changeset 38238 | 43c13eb0d842 |
| parent 35024 | 0faeabd99289 |
| permissions | -rwxr-xr-x |
|
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 | 19 |
if ($group eq "group") {
|
20 |
use POSIX "setsid"; |
|
| 26107 | 21 |
POSIX::setsid || die $!; |
| 26096 | 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'/; |