[monitoring-plugins] tests: ignore sigpipes in https test daemon

Sven Nierlein git at monitoring-plugins.org
Thu May 20 21:10:12 CEST 2021


 Module: monitoring-plugins
 Branch: feature_github_actions
 Commit: b428cc17f75682465e6f1e59b32fdec02b87ceac
 Author: Sven Nierlein <sven at nierlein.de>
   Date: Thu May 20 20:57:59 2021 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=b428cc1

tests: ignore sigpipes in https test daemon

check_http closes the connection after checking the certificate with -C. This leads to sigpipe
errors when the ssl daemon wants to send a response and the daemon quits which makes the
subsequent tests fail.

---

 plugins/tests/check_http.t | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t
index 0f56950..188f5e7 100755
--- a/plugins/tests/check_http.t
+++ b/plugins/tests/check_http.t
@@ -91,6 +91,8 @@ if ($pid) {
 				exit;
 			}
 		} else {
+			# closing the connection after -C cert checks make the daemon exit with a sigpipe otherwise
+			local $SIG{'PIPE'} = 'IGNORE';
 			my $d = HTTP::Daemon::SSL->new(
 				LocalPort => $port_https,
 				LocalAddr => "127.0.0.1",
@@ -415,22 +417,24 @@ sub run_common_tests {
 
 	# stickyport - on full urlS port is set back to 80 otherwise
 	$cmd = "$command -f stickyport -u /redir_external -t 5 -s redirected";
+	alarm(2);
 	eval {
 		local $SIG{ALRM} = sub { die "alarm\n" };
-		alarm(2);
 		$result = NPTest->testCmd( $cmd );
-		alarm(0);	};
+	};
 	isnt( $@, "alarm\n", $cmd );
+	alarm(0);
 	is( $result->return_code, 0, $cmd );
 
 	# Let's hope there won't be any web server on :80 returning "redirected"!
 	$cmd = "$command -f sticky -u /redir_external -t 5 -s redirected";
+	alarm(2);
 	eval {
 		local $SIG{ALRM} = sub { die "alarm\n" };
-		alarm(2);
 		$result = NPTest->testCmd( $cmd );
-		alarm(0); };
+	};
 	isnt( $@, "alarm\n", $cmd );
+	alarm(0);
 	isnt( $result->return_code, 0, $cmd );
 
 	# Test an external address - timeout



More information about the Commits mailing list