Skip to content

Commit b6811f8

Browse files
committed
[perl #121028] avoid creating a shell process
Win32 now has list form open, so this can now be supplied.
1 parent aed76e6 commit b6811f8

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

t/io/openpid.t

+15-5
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,38 @@ watchdog(15, $^O eq 'MSWin32' ? "alarm" : '');
2323
use Config;
2424
$| = 1;
2525
$SIG{PIPE} = 'IGNORE';
26+
# reset the handler in case the shell has set a broken default
27+
$SIG{HUP} = 'DEFAULT';
2628
$SIG{HUP} = 'IGNORE' if $^O eq 'interix';
2729

2830
my $perl = which_perl();
2931
$perl .= qq[ "-I../lib"];
3032

33+
my @perl = ( which_perl(), "-I../lib" );
34+
3135
#
3236
# commands run 4 perl programs. Two of these programs write a
3337
# short message to STDOUT and exit. Two of these programs
3438
# read from STDIN. One reader never exits and must be killed.
3539
# the other reader reads one line, waits a few seconds and then
3640
# exits to test the waitpid function.
3741
#
38-
$cmd1 = qq/$perl -e "\$|=1; print qq[first process\\n]; sleep 30;"/;
39-
$cmd2 = qq/$perl -e "\$|=1; print qq[second process\\n]; sleep 30;"/;
42+
# Using 4+ arg open for the children that sleep so that that we're
43+
# killing the perl process instead of an intermediate shell, this
44+
# allows harness to see the file handles closed sooner. I didn't
45+
# convert them all since I wanted 3-arg open to continue to be
46+
# exercised here.
47+
#
48+
@cmd1 = ( @perl, "-e", "\$|=1; print qq[first process\\n]; sleep 30;" );
49+
@cmd2 = ( @perl, "-e", "\$|=1; print qq[second process\\n]; sleep 30;" );
4050
$cmd3 = qq/$perl -e "print <>;"/; # hangs waiting for end of STDIN
4151
$cmd4 = qq/$perl -e "print scalar <>;"/;
4252

43-
#warn "#$cmd1\n#$cmd2\n#$cmd3\n#$cmd4\n";
53+
#warn "#@cmd1\n#@cmd2\n#$cmd3\n#$cmd4\n";
4454

4555
# start the processes
46-
ok( $pid1 = open(FH1, "$cmd1 |"), 'first process started');
47-
ok( $pid2 = open(FH2, "$cmd2 |"), ' second' );
56+
ok( $pid1 = open(FH1, "-|", @cmd1), 'first process started');
57+
ok( $pid2 = open(FH2, "-|", @cmd2), ' second' );
4858
{
4959
no warnings 'once';
5060
ok( $pid3 = open(FH3, "| $cmd3"), ' third' );

0 commit comments

Comments
 (0)