From: Ian Jackson Date: Thu, 11 Aug 2022 23:39:15 +0000 (+0100) Subject: prefork-interp: improve protocol exchange error handling X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=commitdiff_plain;h=85561802668caec4a49470a255d4a393b3eb6beb prefork-interp: improve protocol exchange error handling Signed-off-by: Ian Jackson --- diff --git a/perl/Prefork.pm b/perl/Prefork.pm index fb54a91..1e3d9d7 100644 --- a/perl/Prefork.pm +++ b/perl/Prefork.pm @@ -76,7 +76,7 @@ sub eintr_retry ($) { sub protocol_read_fail ($) { my ($what) = @_; _exit(0) if $!==ECONNRESET; - fail_log("recv $what: $!"); + die("recv $what: $!"); } sub protocol_exchange () { @@ -104,12 +104,12 @@ sub protocol_exchange () { $r == $len or _exit(0); @ARGV = split /\0/, $data; - @ARGV >= 2 or fail_log("message data has too few strings"); - length(pop(@ARGV)) and fail_log("message data missing trailing nul"); + @ARGV >= 2 or die("message data has too few strings"); + length(pop(@ARGV)) and die("message data missing trailing nul"); %ENV = (); while (my $s = shift @ARGV) { last if !length $s; - $s =~ m/=/ or fail_log("message data env var missing equals"); + $s =~ m/=/ or die("message data env var missing equals"); $ENV{$`} = $'; } } @@ -206,7 +206,8 @@ sub initialisation_complete { if (!$child) { #---- monitor [1] ---- close LISTEN; - protocol_exchange(); + eval { protocol_exchange(); 1; } + or fail_log("protocol exchange failed: $@"); return become_monitor(); } close(CALL);