summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2014-01-28 15:52:22 +1100
committerTony Cook <tony@develop-help.com>2018-02-15 14:42:57 +1100
commitb6811f8d3a5c4826ad03be7b9dc69f5f3dc939be (patch)
tree831cb311a528a1ed956f918f0d5c92dcdec7907c
parentaed76e69bd9a87baa8ab250f3e953beb2779f66e (diff)
downloadperl-b6811f8d3a5c4826ad03be7b9dc69f5f3dc939be.tar.gz
[perl #121028] avoid creating a shell process
Win32 now has list form open, so this can now be supplied.
-rw-r--r--t/io/openpid.t20
1 files changed, 15 insertions, 5 deletions
diff --git a/t/io/openpid.t b/t/io/openpid.t
index d3fcf7869a..634330ded7 100644
--- a/t/io/openpid.t
+++ b/t/io/openpid.t
@@ -23,11 +23,15 @@ watchdog(15, $^O eq 'MSWin32' ? "alarm" : '');
use Config;
$| = 1;
$SIG{PIPE} = 'IGNORE';
+# reset the handler in case the shell has set a broken default
+$SIG{HUP} = 'DEFAULT';
$SIG{HUP} = 'IGNORE' if $^O eq 'interix';
my $perl = which_perl();
$perl .= qq[ "-I../lib"];
+my @perl = ( which_perl(), "-I../lib" );
+
#
# commands run 4 perl programs. Two of these programs write a
# short message to STDOUT and exit. Two of these programs
@@ -35,16 +39,22 @@ $perl .= qq[ "-I../lib"];
# the other reader reads one line, waits a few seconds and then
# exits to test the waitpid function.
#
-$cmd1 = qq/$perl -e "\$|=1; print qq[first process\\n]; sleep 30;"/;
-$cmd2 = qq/$perl -e "\$|=1; print qq[second process\\n]; sleep 30;"/;
+# Using 4+ arg open for the children that sleep so that that we're
+# killing the perl process instead of an intermediate shell, this
+# allows harness to see the file handles closed sooner. I didn't
+# convert them all since I wanted 3-arg open to continue to be
+# exercised here.
+#
+@cmd1 = ( @perl, "-e", "\$|=1; print qq[first process\\n]; sleep 30;" );
+@cmd2 = ( @perl, "-e", "\$|=1; print qq[second process\\n]; sleep 30;" );
$cmd3 = qq/$perl -e "print <>;"/; # hangs waiting for end of STDIN
$cmd4 = qq/$perl -e "print scalar <>;"/;
-#warn "#$cmd1\n#$cmd2\n#$cmd3\n#$cmd4\n";
+#warn "#@cmd1\n#@cmd2\n#$cmd3\n#$cmd4\n";
# start the processes
-ok( $pid1 = open(FH1, "$cmd1 |"), 'first process started');
-ok( $pid2 = open(FH2, "$cmd2 |"), ' second' );
+ok( $pid1 = open(FH1, "-|", @cmd1), 'first process started');
+ok( $pid2 = open(FH2, "-|", @cmd2), ' second' );
{
no warnings 'once';
ok( $pid3 = open(FH3, "| $cmd3"), ' third' );