From 3f8f46c8b10d060ec4ba7f3be91ff3cb6e903e01 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Sun, 12 Nov 2017 11:48:02 -0500 Subject: Remove child handling, replace with pipe signal handling. We don't actually care about the child, really, just ability to read and write, so SIGPIPE is more appropriate. Currently, ignore SIGPIPE during write operations, to support just spamming input for protocol dump testing. This should be a flag in the future, but for now, as long as there's a match step with a thunk, it'll get caught there. --- xmpt | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/xmpt b/xmpt index 37af263..9ab7f7d 100755 --- a/xmpt +++ b/xmpt @@ -27,12 +27,9 @@ usage(0) if $help; my %conf = read_conf($configpath); my @plans = load_plans($testplanpath, $templatepath); -my $curstep; -local $SIG{CHLD} = sub { - my $suffix = "before test plan started."; - $suffix = "in $curstep step." if $curstep; - die "Command '@ARGV' terminated $suffix\n" -}; +# Ignore SIGPIPE at the top level, since it only matters when reading +# or writing to the subprocess. +local $SIG{PIPE} = sub {}; my ($inh, $outh) = (\*STDIN, \*STDOUT); my $pid; @@ -160,8 +157,7 @@ sub eval_in { eval { foreach my $plan (@plans) { - $curstep = $plan->{name}; - print STDERR "=> Executing $curstep step.\n" if $verbose; + print STDERR "=> Executing $plan->{name} step.\n" if $verbose; do_send($plan->{name}, @{$plan->{send}}); do_recv($plan->{name}, @{$plan->{expect}}) if $plan->{expect}; } @@ -177,6 +173,11 @@ sub do_send { chomp $l; print STDERR "SEND: $l\n" unless $l =~ /^\s*$/; } + + # TODO: make write SIGPIPE configurable, but for now just ignore it. + local $SIG{PIPE} = sub { + print STDERR "Warning: SIGPIPE received from '@ARGV' while writing in $name step.\n" + }; print $evalpkg::out $s; } @@ -208,6 +209,9 @@ sub do_recv { chomp $b; die "Timed out waiting for match in $name step. Current read buffer:\n$b\n"; }; + local $SIG{PIPE} = sub { + die "SIGPIPE received from '@ARGV' while matching in $name step.\n"; + }; alarm $timeout; my @matches; while (1) { -- cgit v1.2.3