[lintian] 01/03: L::Command: Add support for a calling a sub in the child
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository lintian.
commit 37cfdf202e86a1b448512b09d42dc0e4ef9f6add
Author: Niels Thykier <niels@thykier.net>
Date: Sun Sep 14 11:14:16 2014 +0200
L::Command: Add support for a calling a sub in the child
Signed-off-by: Niels Thykier <niels@thykier.net>
---
debian/changelog | 4 ++++
lib/Lintian/Command.pm | 22 +++++++++++++++++++++-
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/debian/changelog b/debian/changelog
index 844aa5e..0027e3d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,10 @@ lintian (2.5.28) UNRELEASED; urgency=medium
XXX: generate tag summary with private/generate-tag-summary
+ * lib/Lintian/Command.pm:
+ + [NT] Add support for running a sub in the child before
+ it calls exec.
+
-- Niels Thykier <niels@thykier.net> Sun, 14 Sep 2014 08:55:45 +0200
lintian (2.5.27) unstable; urgency=medium
diff --git a/lib/Lintian/Command.pm b/lib/Lintian/Command.pm
index db4b534..2b7bf09 100644
--- a/lib/Lintian/Command.pm
+++ b/lib/Lintian/Command.pm
@@ -139,6 +139,13 @@ with a non-zero error code. If exceptions should be handled by the caller,
setting it to 'never' will cause it to store the exception in the
C<exception> key instead.
+=item child_before_exec
+
+Run the given subroutine in each of the children before they run
+"exec".
+
+This is passed to L<IPC::Run/harness> as the I<init> keyword.
+
=back
The following additional keys will be set during the execution of spawn():
@@ -174,7 +181,7 @@ sub spawn {
$opts->{fail} ||= 'exception';
my ($out, $background);
- my (@out, @in, @err);
+ my (@out, @in, @err, @kwargs);
if ($opts->{pipe_in}) {
@in = ('<pipe', $opts->{pipe_in});
$background = 1;
@@ -213,6 +220,19 @@ sub spawn {
}
}
+ if ($opts->{'child_before_exec'}) {
+ push(@kwargs, 'init', $opts->{'child_before_exec'});
+ @cmds = map {
+ # The init handler has to be injected after each
+ # command but (presumably) before the '|' or '&'.
+ if (ref($_) eq 'ARRAY') {
+ ($_, @kwargs);
+ } else {
+ $_;
+ }
+ } @cmds;
+ }
+
eval {
if (@cmds == 1) {
my $cmd = pop @cmds;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: