Commit | Line | Data |
---|---|---|
e9d373c4 TC |
1 | #!./perl |
2 | ||
3 | BEGIN { | |
4 | chdir 't' if -d 't'; | |
624c42e2 N |
5 | require "./test.pl"; |
6 | set_up_inc('../lib'); | |
e9d373c4 TC |
7 | } |
8 | ||
e9d373c4 TC |
9 | plan tests => 3; |
10 | watchdog(10, $^O eq 'MSWin32' ? "alarm" : ''); | |
11 | ||
12 | use Config; | |
13 | $| = 1; | |
14 | $SIG{PIPE} = 'IGNORE'; | |
af1f7e28 TC |
15 | # work around a shell set to ignore HUP |
16 | $SIG{HUP} = 'DEFAULT'; | |
e9d373c4 TC |
17 | $SIG{HUP} = 'IGNORE' if $^O eq 'interix'; |
18 | ||
19 | my $perl = which_perl(); | |
e9d373c4 TC |
20 | |
21 | my $killsig = 'HUP'; | |
22 | $killsig = 1 unless $Config{sig_name} =~ /\bHUP\b/; | |
23 | ||
24 | SKIP: | |
25 | { | |
26 | skip("Not relevant to $^O", 3) | |
27 | if $^O eq "MSWin32" || $^O eq "VMS"; | |
28 | skip("only matters for waitpid or wait4", 3) | |
29 | unless $Config{d_waitpid} || $Config{d_wait4}; | |
30 | # [perl #119893] | |
31 | # close on the original of a popen handle dupped to a standard handle | |
32 | # would wait4pid(0, ...) | |
33 | open my $savein, "<&", \*STDIN; | |
af1f7e28 | 34 | my $pid = open my $fh1, "-|", $perl, "-e", "sleep 50"; |
e9d373c4 TC |
35 | ok($pid, "open a pipe"); |
36 | # at this point PL_fdpids[fileno($fh1)] is the pid of the new process | |
37 | ok(open(STDIN, "<&=", $fh1), "dup the pipe"); | |
38 | # now PL_fdpids[fileno($fh1)] is zero and PL_fdpids[0] is | |
39 | # the pid of the process created above, previously this would block | |
40 | # internally on waitpid(0, ...) | |
41 | ok(close($fh1), "close the original"); | |
42 | kill $killsig, $pid; | |
43 | open STDIN, "<&", $savein; | |
44 | } |