-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PATCH] t/io/closepid.t hangs for test timeout (50 seconds) under harness #13535
Comments
From @wolfsageCreated by wolfsage@gmail.com$ time ./perl harness io/closepid.t io/closepid.t .. ok real 0m50.079s With patch: $ time ./perl harness io/closepid.t real 0m0.093s The problem seems to be that the test is forking a perl process like so: my $pid = open my $fh1, qq/$perl -e "sleep 50" |/; Which starts two processes, 'sh -c "$perl -e \"sleep 50\""' and the perl -e... The pid from sh is returned, and later we try to clean up by sending it a HUP: kill $killsig, $pid; On my system, sh -c ".." doesn't exit on a HUP, but it does on a TERM. I've updated the test to use TERM instead, however I'm not sure if this Tony, it looks like you added this in e9d373c, can you comment? Thanks, -- Matthew Horsfall (alh) Perl Info
|
From @wolfsage0001-Switch-from-HUP-to-TERM-so-test-sub-process-exits-wh.patchFrom 0483c09e8bfccff1b4255f178be5fd012bc0da11 Mon Sep 17 00:00:00 2001
From: Matthew Horsfall <WolfSage@gmail.com>
Date: Fri, 17 Jan 2014 18:33:08 -0500
Subject: [PATCH] Switch from HUP to TERM so test sub-process exits when asked
for under harness.
'make test' does not show the slow behaviour (t/TEST), only under
TAP::Harness (t/harness) do we see it.
---
t/io/closepid.t | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/t/io/closepid.t b/t/io/closepid.t
index aa937f5..bdd8c8e 100644
--- a/t/io/closepid.t
+++ b/t/io/closepid.t
@@ -16,13 +16,13 @@ watchdog(10, $^O eq 'MSWin32' ? "alarm" : '');
use Config;
$| = 1;
$SIG{PIPE} = 'IGNORE';
-$SIG{HUP} = 'IGNORE' if $^O eq 'interix';
+$SIG{TERM} = 'IGNORE' if $^O eq 'interix';
my $perl = which_perl();
$perl .= qq[ "-I../lib"];
-my $killsig = 'HUP';
-$killsig = 1 unless $Config{sig_name} =~ /\bHUP\b/;
+my $killsig = 'TERM';
+$killsig = 15 unless $Config{sig_name} =~ /\bTERM\b/;
SKIP:
{
--
1.7.9.5
|
From @tonycozOn Fri Jan 17 15:36:14 2014, alh wrote:
The change in signal should make no difference to what test is trying to test for and I can reproduce the delay you see. Your change doesn't make any difference to the delay for me though: # blead is 3ac2191 real 0m50.124s Switch from HUP to TERM so test sub-process exits when asked for under harne Inline Patchdiff --git a/t/io/closepid.t b/t/io/closepid.t
index aa937f5..bdd8c8e 100644
--- a/t/io/closepid.t
+++ b/t/io/closepid.t
@@ -16,13 +16,13 @@ watchdog(10, $^O eq 'MSWin32' ? "alarm" : '');
use Config;
$| = 1;
$SIG{PIPE} = 'IGNORE';
-$SIG{HUP} = 'IGNORE' if $^O eq 'interix';
+$SIG{TERM} = 'IGNORE' if $^O eq 'interix';
my $perl = which_perl();
$perl .= qq[ "-I../lib"];
-my $killsig = 'HUP';
-$killsig = 1 unless $Config{sig_name} =~ /\bHUP\b/;
+my $killsig = 'TERM';
+$killsig = 15 unless $Config{sig_name} =~ /\bTERM\b/;
SKIP:
{
real 0m50.108s A different approach is to not use the shell, please let me know if the attached fixes the problem for you. Tony |
From @tonycoz0001-perl-121028-avoid-creating-a-shell-process.patchFrom 4b0a73e22aa3e59e48b32ef2409ea89ed5c3f125 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Mon, 20 Jan 2014 09:39:19 +1100
Subject: [perl #121028] avoid creating a shell process
---
t/io/closepid.t | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/t/io/closepid.t b/t/io/closepid.t
index aa937f5..b9e9e15 100644
--- a/t/io/closepid.t
+++ b/t/io/closepid.t
@@ -19,7 +19,6 @@ $SIG{PIPE} = 'IGNORE';
$SIG{HUP} = 'IGNORE' if $^O eq 'interix';
my $perl = which_perl();
-$perl .= qq[ "-I../lib"];
my $killsig = 'HUP';
$killsig = 1 unless $Config{sig_name} =~ /\bHUP\b/;
@@ -34,7 +33,7 @@ SKIP:
# close on the original of a popen handle dupped to a standard handle
# would wait4pid(0, ...)
open my $savein, "<&", \*STDIN;
- my $pid = open my $fh1, qq/$perl -e "sleep 50" |/;
+ my $pid = open my $fh1, "-|", $perl, "-e", "sleep 50";
ok($pid, "open a pipe");
# at this point PL_fdpids[fileno($fh1)] is the pid of the new process
ok(open(STDIN, "<&=", $fh1), "dup the pipe");
--
1.7.10.4
|
The RT System itself - Status changed from 'new' to 'open' |
From @wolfsageOn Sun, Jan 19, 2014 at 5:42 PM, Tony Cook via RT
Your patch doesn't fix it for me - my perl doesn't exit on a SIGHUP. Perhaps your patch + SIGTERM, or some other way to signal to the child -- Matthew Horsfall (alh) |
From @wolfsageWhatever the solution, t/io/openpid.t suffers the same problem and can -- Matthew Horsfall (alh) |
From @LeontOn Mon Jan 20 06:26:02 2014, alh wrote:
What is the output of this command on your system? perl -MPOSIX=sigprocmask,SIG_SETMASK -E 'sigprocmask(SIG_SETMASK, undef, my $set = POSIX::SigSet->new); say join "", map $set->ismember($_), 1 .. 32' Leon |
From @wolfsageOn Mon, Jan 20, 2014 at 8:10 PM, Leon Timmermans via RT
mhorsfall@tworivers:~$ perl -MPOSIX=sigprocmask,SIG_SETMASK -E mhorsfall@tworivers:~$ uname -a -- Matthew Horsfall (alh) |
From @wolfsageOn Tue, Jan 21, 2014 at 9:16 AM, Matthew Horsfall (alh)
Oddly, my other ubuntu box (Which is ubuntu server instead of ubuntu mhorsfall@dory:~$ uname -a -- Matthew Horsfall (alh) |
From @LeontOn Tue, Jan 21, 2014 at 3:16 PM, Matthew Horsfall (alh)
And how about « perl -E 'say $SIG{HUP}' » ? Leon |
From @wolfsageOn Tue, Jan 21, 2014 at 9:37 AM, Leon Timmermans <fawaka@gmail.com> wrote:
mhorsmhorsfall@tworivers:~/perl-1$ ./perl -Ilib -E 'say $SIG{HUP}' What's going on here? -- Matthew Horsfall (alh) |
From @LeontOn Tue, Jan 21, 2014 at 4:08 PM, Matthew Horsfall (alh)
Something sets up your environment to ignore SIGHUP by default. Possibly a Leon |
From @tonycozOn Mon Jan 20 06:26:02 2014, alh wrote:
The attached patch allows closepid() to finish quickly for me in a shell with C< trap "" HUP >. This makes sure that $SIG{HUP} is DEFAULT before we expect it to work, though perhaps it should just skip when $SIG{HUP} and complain your system is broken. Preventing openpid.t from delaying processing would require similar changes I think - using 3+ arg open for the pipe opens (to avoid the extra processes) and preventing $SIG{HUP} being ignored. Note that the problem in both cases isn't that (open|close)pid.t is waiting, but that harness is waiting for the stdout handle from the children to be closed. Tony |
From @tonycoz0001-perl-121028-avoid-creating-a-shell-process.patchFrom 0bc4d3b37fc2ae0ffd41dc5d358e50f33da7ff33 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Wed, 22 Jan 2014 15:14:59 +1100
Subject: [PATCH] [perl #121028] avoid creating a shell process
---
t/io/closepid.t | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/t/io/closepid.t b/t/io/closepid.t
index aa937f5..a90db68 100644
--- a/t/io/closepid.t
+++ b/t/io/closepid.t
@@ -16,10 +16,11 @@ watchdog(10, $^O eq 'MSWin32' ? "alarm" : '');
use Config;
$| = 1;
$SIG{PIPE} = 'IGNORE';
+# work around a shell set to ignore HUP
+$SIG{HUP} = 'DEFAULT';
$SIG{HUP} = 'IGNORE' if $^O eq 'interix';
my $perl = which_perl();
-$perl .= qq[ "-I../lib"];
my $killsig = 'HUP';
$killsig = 1 unless $Config{sig_name} =~ /\bHUP\b/;
@@ -34,7 +35,7 @@ SKIP:
# close on the original of a popen handle dupped to a standard handle
# would wait4pid(0, ...)
open my $savein, "<&", \*STDIN;
- my $pid = open my $fh1, qq/$perl -e "sleep 50" |/;
+ my $pid = open my $fh1, "-|", $perl, "-e", "sleep 50";
ok($pid, "open a pipe");
# at this point PL_fdpids[fileno($fh1)] is the pid of the new process
ok(open(STDIN, "<&=", $fh1), "dup the pipe");
--
1.7.10.4
|
From @wolfsageOn Tue, Jan 21, 2014 at 11:46 PM, Tony Cook via RT
Awesome, this works great for me. How do you feel about applying this to other places where If you're busy I'd be willing to throw this together. Thanks, -- Matthew Horsfall (alh) |
From @tonycozOn Fri Jan 24 05:08:05 2014, alh wrote:
The attached patch allows openpid.t to finish quickly under harness on Linux - *but* fails horribly on Win32: C:\Users\tony\dev\perl\git\perl\t>.\perl io\openpid.t Implementing list form pipes on Win32 is complicated by there being no standard command-line argument parsing mechanism - apparently VB for example uses different rules to the CRT. This isn't a problem for closepid.t, since that test is skipped on Win32. An option might be to implement list form pipes for Win32, but I'm not sure I want to jump down that rabbit hole. Tony |
From @tonycoz0001-perl-121028-avoid-creating-a-shell-process.patchFrom 0fd13b4b4422d848e9b1dcaacf8800a17a1f7cdb Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Tue, 28 Jan 2014 15:52:22 +1100
Subject: [PATCH] [perl #121028] avoid creating a shell process
---
t/io/closepid.t | 5 +++--
t/io/openpid.t | 20 +++++++++++++++-----
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/t/io/closepid.t b/t/io/closepid.t
index aa937f5..a90db68 100644
--- a/t/io/closepid.t
+++ b/t/io/closepid.t
@@ -16,10 +16,11 @@ watchdog(10, $^O eq 'MSWin32' ? "alarm" : '');
use Config;
$| = 1;
$SIG{PIPE} = 'IGNORE';
+# work around a shell set to ignore HUP
+$SIG{HUP} = 'DEFAULT';
$SIG{HUP} = 'IGNORE' if $^O eq 'interix';
my $perl = which_perl();
-$perl .= qq[ "-I../lib"];
my $killsig = 'HUP';
$killsig = 1 unless $Config{sig_name} =~ /\bHUP\b/;
@@ -34,7 +35,7 @@ SKIP:
# close on the original of a popen handle dupped to a standard handle
# would wait4pid(0, ...)
open my $savein, "<&", \*STDIN;
- my $pid = open my $fh1, qq/$perl -e "sleep 50" |/;
+ my $pid = open my $fh1, "-|", $perl, "-e", "sleep 50";
ok($pid, "open a pipe");
# at this point PL_fdpids[fileno($fh1)] is the pid of the new process
ok(open(STDIN, "<&=", $fh1), "dup the pipe");
diff --git a/t/io/openpid.t b/t/io/openpid.t
index 946fa5e..de75648 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' );
--
1.7.10.4
|
From @LeontOn Tue, Jan 28, 2014 at 6:48 AM, Tony Cook via RT <perlbug-followup@perl.org
I think that would be highly desirable anyway. I'd second only to unicode Leon |
From @tonycozOn Tue Jan 21 20:46:07 2014, tonyc wrote:
I've applied the closepid.t change to blead as af1f7e2. I don't think it needs a perldelta entry. I'll leave this ticket open until list form pipe is available on Win32 and a similar change can be made to io/openpid.t Tony |
From @tonycozOn Mon, 03 Feb 2014 15:41:46 -0800, tonyc wrote:
Which was done in b6811f8. Tony |
@tonycoz - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank you for filing this report. You have helped make Perl better. With the release yesterday of Perl 5.28.0, this and 185 other issues have been Perl 5.28.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#121028 (status was 'resolved')
Searchable as RT121028$
The text was updated successfully, but these errors were encountered: