From: Dan Fandrich Date: Wed, 17 May 2023 05:34:40 +0000 (-0700) Subject: runtests: handle interrupted reads from IPC pipes X-Git-Tag: curl-8_1_1~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b43915b38fbf9a2e8890794fe90405c5a75c612b;p=thirdparty%2Fcurl.git runtests: handle interrupted reads from IPC pipes These can be interrupted by signals, especially SIGINT to shut down, and must be restarted so the IPC call arrives correctly. If the read just returns an error instead, the IPC calling state will go out of sync and a proper shutdown won't happen. Ref: #10818 --- diff --git a/tests/runner.pm b/tests/runner.pm index 879ed0e98c..89182004bf 100644 --- a/tests/runner.pm +++ b/tests/runner.pm @@ -1203,14 +1203,17 @@ sub controlleripccall { # Called by controller sub runnerar { my ($runnerid) = @_; + my $err; my $datalen; - if (sysread($controllerr{$runnerid}, $datalen, 4) <= 0) { - die "error in runnerar\n"; + while(! defined ($err = sysread($controllerr{$runnerid}, $datalen, 4)) || $err <= 0) { + $!{EINTR} || die "error in runnerar: $!\n"; + # system call was interrupted, probably by ^C; restart it so we stay in sync } my $len=unpack("L", $datalen); my $buf; - if (sysread($controllerr{$runnerid}, $buf, $len) <= 0) { - die "error in runnerar\n"; + while(! defined ($err = sysread($controllerr{$runnerid}, $buf, $len)) || $err <= 0) { + $!{EINTR} || die "error in runnerar: $!\n"; + # system call was interrupted, probably by ^C; restart it so we stay in sync } # Decode response values @@ -1259,14 +1262,17 @@ sub runnerar_ready { # The IPC is read from the $runnerr pipe and the response is # written to the $runnerw pipe sub ipcrecv { + my $err; my $datalen; - if (sysread($runnerr, $datalen, 4) <= 0) { - die "error in ipcrecv\n"; + while(! defined ($err = sysread($runnerr, $datalen, 4)) || $err <= 0) { + $!{EINTR} || die "error in ipcrecv: $!\n"; + # system call was interrupted, probably by ^C; restart it so we stay in sync } my $len=unpack("L", $datalen); my $buf; - if (sysread($runnerr, $buf, $len) <= 0) { - die "error in ipcrecv\n"; + while(! defined ($err = sysread($runnerr, $buf, $len)) || $err <= 0) { + $!{EINTR} || die "error in ipcrecv: $!\n"; + # system call was interrupted, probably by ^C; restart it so we stay in sync } # Decode the function name and arguments