summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2003-09-11 12:50:05 +0000
committerFrancois Pons <fpons@mandriva.com>2003-09-11 12:50:05 +0000
commit4128297ab08cb1236ffaec377fa09b27b2506665 (patch)
treefe9f2d05360c20621c019ef29162d1120178b8fe
parent17f770f1e961fc4f9b2f21f2ec608c023ad1e218 (diff)
downloaddrakx-4128297ab08cb1236ffaec377fa09b27b2506665.tar
drakx-4128297ab08cb1236ffaec377fa09b27b2506665.tar.gz
drakx-4128297ab08cb1236ffaec377fa09b27b2506665.tar.bz2
drakx-4128297ab08cb1236ffaec377fa09b27b2506665.tar.xz
drakx-4128297ab08cb1236ffaec377fa09b27b2506665.zip
added detach option to handle detached process running (for update-menus).
-rw-r--r--perl-install/run_program.pm58
1 files changed, 31 insertions, 27 deletions
diff --git a/perl-install/run_program.pm b/perl-install/run_program.pm
index 025feae2d..027944d56 100644
--- a/perl-install/run_program.pm
+++ b/perl-install/run_program.pm
@@ -58,37 +58,41 @@ sub raw {
my $stderr = $stderr_raw && (ref($stderr_raw) ? "$ENV{HOME}/tmp/.drakx-stderr.$$" : "$root$stderr_raw");
if (my $pid = fork()) {
- my $ok;
- eval {
- local $SIG{ALRM} = sub { die "ALARM" };
- alarm($options->{timeout} || 10 * 60);
- waitpid $pid, 0;
- $ok = $? == 0;
- alarm 0;
- };
- if ($@) {
- log::l("ERROR: killing runaway process");
- kill 9, $pid;
- return;
- }
+ if ($options->{detach}) {
+ $pid;
+ } else {
+ my $ok;
+ eval {
+ local $SIG{ALRM} = sub { die "ALARM" };
+ alarm($options->{timeout} || 10 * 60);
+ waitpid $pid, 0;
+ $ok = $? == 0;
+ alarm 0;
+ };
+ if ($@) {
+ log::l("ERROR: killing runaway process");
+ kill 9, $pid;
+ return;
+ }
- if ($stdout_raw && ref($stdout_raw)) {
- if (ref($stdout_raw) eq 'ARRAY') {
- @$stdout_raw = cat_($stdout);
- } else {
- $$stdout_raw = cat_($stdout);
+ if ($stdout_raw && ref($stdout_raw)) {
+ if (ref($stdout_raw) eq 'ARRAY') {
+ @$stdout_raw = cat_($stdout);
+ } else {
+ $$stdout_raw = cat_($stdout);
+ }
+ unlink $stdout;
}
- unlink $stdout;
- }
- if ($stderr_raw && ref($stderr_raw)) {
- if (ref($stderr_raw) eq 'ARRAY') {
- @$stderr_raw = cat_($stderr);
- } else {
- $$stderr_raw = cat_($stderr);
+ if ($stderr_raw && ref($stderr_raw)) {
+ if (ref($stderr_raw) eq 'ARRAY') {
+ @$stderr_raw = cat_($stderr);
+ } else {
+ $$stderr_raw = cat_($stderr);
+ }
+ unlink $stderr;
}
- unlink $stderr;
+ $ok;
}
- $ok;
} else {
if ($stderr && $stderr eq 'STDERR') {
} elsif ($stderr) {