[SCM] Debian package checker branch, infra-513663, updated. 2.5.0-rc1-121-g96b50fe
The following commit has been merged in the infra-513663 branch:
commit 901a8fbde2e2752b633b85cfb366ec9c664bcc25
Author: Niels Thykier <niels@thykier.net>
Date: Fri Apr 1 21:38:00 2011 +0200
Added a dir version of background (similar to rundir)
diff --git a/lib/Lintian/Command/Simple.pm b/lib/Lintian/Command/Simple.pm
index 2ab34ea..b8a3573 100644
--- a/lib/Lintian/Command/Simple.pm
+++ b/lib/Lintian/Command/Simple.pm
@@ -187,6 +187,50 @@ sub background {
}
}
+=item background_dir(dir, command, argument [, ...])
+
+Executes the given C<command> with the given arguments asynchronously
+in dir and returns the process id of the child process.
+
+A return value of -1 indicates an error. This can either be a problem
+when calling CORE::fork() or when trying to run another command before
+calling wait() to reap the previous command.
+
+=cut
+
+sub background_dir {
+ my $self;
+
+ if (ref $_[0]) {
+ $self = shift;
+ return -1
+ if (defined($self->{'pid'}));
+
+ $self->{'status'} = undef;
+ }
+
+ my $pid = fork();
+
+ if (not defined($pid)) {
+ # failed
+ return -1;
+ } elsif ($pid > 0) {
+ # parent
+
+ $self->{'pid'} = $pid
+ if (defined($self));
+
+ return $pid;
+ } else {
+ # child
+ my $dir = shift;
+ close(STDIN);
+ open(STDIN, '<', '/dev/null');
+ chdir($dir) or die("Failed to chdir to $dir: $!\n");
+ CORE::exec @_ or die("Failed to exec '$_[0]': $!\n");
+ }
+}
+
=item wait([pid|hashref])
When called as a function:
--
Debian package checker
Reply to: