diff options
author | Nicholas Clark <nick@ccl4.org> | 2012-07-31 15:06:33 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2013-05-28 09:19:29 +0200 |
commit | 12641c3bc3b66b6b08b7feeca89a7cc24aa0fe9c (patch) | |
tree | 95c528353c071770066adf40a0e94a7f67801ccb /Porting | |
parent | 37c43f74cd68c954889e0575e0b11c4074904f9c (diff) | |
download | perl-12641c3bc3b66b6b08b7feeca89a7cc24aa0fe9c.tar.gz |
In bisect-runner.pl, extract the Configure running into run_with_options().
Configure is run using explicit fork, exec and waitpid so that it can be run
with with STDIN from /dev/null, but without going through the shell (to
avoid having to worry about quoting command line arguments). This code will
be useful for adding optional timeouts when running the user test case.
Diffstat (limited to 'Porting')
-rwxr-xr-x | Porting/bisect-runner.pl | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/Porting/bisect-runner.pl b/Porting/bisect-runner.pl index 31cd290c09..b3963a563b 100755 --- a/Porting/bisect-runner.pl +++ b/Porting/bisect-runner.pl @@ -711,6 +711,26 @@ sub system_or_die { system($command) and croak_255("'$command' failed, \$!=$!, \$?=$?"); } +sub run_with_options { + my $options = shift; + my $name = $options->{name}; + $name = "@_" unless defined $name; + + my $pid = fork; + die_255("Can't fork: $!") unless defined $pid; + if (!$pid) { + if (exists $options->{stdin}) { + open STDIN, '<', $options->{stdin} + or die "Can't open STDIN from $options->{stdin}: $!"; + } + { exec @_ }; + die_255("Failed to start $name: $!"); + } + waitpid $pid, 0 + or die_255("wait for $name, pid $pid failed: $!"); + return $?; +} + sub extract_from_file { my ($file, $rx, $default) = @_; my $fh = open_or_die($file); @@ -1139,21 +1159,13 @@ foreach my $key (sort keys %defines) { } push @ARGS, map {"-A$_"} @{$options{A}}; -# </dev/null because it seems that some earlier versions of Configure can -# call commands in a way that now has them reading from stdin (and hanging) -my $pid = fork; -die_255("Can't fork: $!") unless defined $pid; -if (!$pid) { - open STDIN, '<', '/dev/null'; - # If a file in MANIFEST is missing, Configure asks if you want to - # continue (the default being 'n'). With stdin closed or /dev/null, - # it exits immediately and the check for config.sh below will skip. - no warnings; # Don't tell me "statement unlikely to be reached". I know. - exec './Configure', @ARGS; - die_255("Failed to start Configure: $!"); -} -waitpid $pid, 0 - or die_255("wait for Configure, pid $pid failed: $!"); +# If a file in MANIFEST is missing, Configure asks if you want to +# continue (the default being 'n'). With stdin closed or /dev/null, +# it exits immediately and the check for config.sh below will skip. +# Without redirecting stdin, the commands called will attempt to read from +# stdin (and thus effectively hang) +run_with_options({stdin => '/dev/null', name => 'Configure'}, + './Configure', @ARGS); patch_SH() unless $options{'all-fixups'}; apply_fixups($options{'late-fixup'}); |