Skip to content

Commit

Permalink
Use open2 for s_client instance
Browse files Browse the repository at this point in the history
  • Loading branch information
fwh-dc committed Jan 22, 2024
1 parent 7930db0 commit 51291de
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions util/perl/TLSProxy/Proxy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ sub clientstart

if ($self->execute) {
my $pid;
my $cin;

my $execcmd = $self->execute
." s_client -engine ossltest"
." -connect $self->{proxy_addr}:$self->{proxy_port}";
Expand Down Expand Up @@ -359,23 +361,15 @@ sub clientstart
print STDERR "Client command: $execcmd\n";
}

open(my $savedout, ">&STDOUT");
# If we open pipe with new descriptor, attempt to close it,
# explicitly or implicitly, would incur waitpid and effectively
# dead-lock...
if (!($pid = open(STDOUT, "| $execcmd"))) {
if (!($pid = IPC::Open2::open2(my $cout, $cin, $execcmd))) {
my $err = $!;
kill(3, $self->{serverpid});
die "Failed to $execcmd: $err\n";
}
$self->{clientpid} = $pid;

# queue [magic] input
print $self->reneg ? "R" : "test";

# this closes client's stdin without waiting for its pid
open(STDOUT, ">&", $savedout);
close($savedout);
print $cin $self->reneg ? "R" : "test";
}

# Wait for incoming connection from client
Expand Down

0 comments on commit 51291de

Please sign in to comment.