system.pl - invoke shell command line (with robust signal handling);
authorwenzelm
Mon, 18 Feb 2008 21:33:29 +0100
changeset 26092 260cca2e16fa
parent 26091 f31d4fe763aa
child 26093 51e8d37b4e7b
system.pl - invoke shell command line (with robust signal handling);
lib/scripts/system.pl
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/scripts/system.pl	Mon Feb 18 21:33:29 2008 +0100
@@ -0,0 +1,26 @@
+#
+# $Id$
+# Author: Makarius
+#
+# system.pl - invoke shell command line (with robust signal handling)
+#
+
+# args
+
+($group, $script_name, $pid_name, $output_name) = @ARGV;
+
+
+# process id
+
+if ($group eq "group") { setpgrp; }
+
+open (PID_FILE, ">", $pid_name) || die $!;
+print PID_FILE "$$\n";
+close PID_FILE;
+
+
+# exec script
+
+$SIG{'INT'} = "DEFAULT";   #paranoia setting, required for Cygwin
+exec qq/exec bash '$script_name' > '$output_name'/;
+