diff net/server_epoll.lua @ 13447:5c9df28a57bb

net.server_epoll: Log failure to hook signals To make any such failures noticeable
author Kim Alvefur <zash@zash.se>
date Wed, 28 Feb 2024 22:24:09 +0100
parents 6d96b6eeee5a
children f36e1e1b84fe
line wrap: on
line diff
--- a/net/server_epoll.lua	Tue Feb 27 17:15:36 2024 +0100
+++ b/net/server_epoll.lua	Wed Feb 28 22:24:09 2024 +0100
@@ -1151,7 +1151,12 @@
 	end
 
 	function hook_signal(signum, cb)
-		local watch = watchfd(signal.signalfd(signum), dispatch);
+		local sigfd = signal.signalfd(signum);
+		if not sigfd then
+			log("error", "Could not hook signal %d", signum);
+			return nil, "failed";
+		end
+		local watch = watchfd(sigfd, dispatch);
 		watch.listeners = { onsignal = cb };
 		watch.close = nil; -- revert to default
 		return watch;