summaryrefslogtreecommitdiffstats
path: root/perl-install/run_program.pm
diff options
context:
space:
mode:
authorChmouel Boudjnah <chmouel@mandriva.org>1999-07-01 12:29:54 +0000
committerChmouel Boudjnah <chmouel@mandriva.org>1999-07-01 12:29:54 +0000
commite1729dfdb9c341fe0b9fed7d7b0a80691a547d82 (patch)
treeb72fd8f59af166fe944ebcf114d648ed5644f752 /perl-install/run_program.pm
parentb50e655e352e2524fb3fb84b2bb4bc96e6a04cf0 (diff)
downloaddrakx-e1729dfdb9c341fe0b9fed7d7b0a80691a547d82.tar
drakx-e1729dfdb9c341fe0b9fed7d7b0a80691a547d82.tar.gz
drakx-e1729dfdb9c341fe0b9fed7d7b0a80691a547d82.tar.bz2
drakx-e1729dfdb9c341fe0b9fed7d7b0a80691a547d82.tar.xz
drakx-e1729dfdb9c341fe0b9fed7d7b0a80691a547d82.zip
"See_The_Changelog"
Diffstat (limited to 'perl-install/run_program.pm')
-rw-r--r--perl-install/run_program.pm30
1 files changed, 30 insertions, 0 deletions
diff --git a/perl-install/run_program.pm b/perl-install/run_program.pm
new file mode 100644
index 000000000..e4f2a7ef8
--- /dev/null
+++ b/perl-install/run_program.pm
@@ -0,0 +1,30 @@
+package run_program;
+
+use diagnostics;
+use strict;
+
+use log;
+
+1;
+
+sub run($@) { rooted('', @_) }
+
+sub rooted($$@) {
+ my ($root, $name, @args) = @_;
+
+ log::l("running: $name @args" . ($root ? " with root $root" : ""));
+ $root ? $root .= '/' : ($root = '');
+
+ fork and wait, return $? == 0;
+ {
+ open STDIN, "/dev/null" or die "can't open /dev/null as stdin";
+
+ open STDERR, ">> /dev/tty5" or open STDERR, ">> /tmp/exec.log" or die "runProgramRoot can't log :(";
+ open STDOUT, ">> /dev/tty5" or open STDOUT, ">> /tmp/exec.log" or die "runProgramRoot can't log :(";
+
+ $root and chroot $root;
+ chdir "/";
+
+ exec $name, @args or log::l("exec of $name failed: $!"), exit(-1);
+ }
+}