net.server_epoll: Log failure to hook signals
authorKim Alvefur <zash@zash.se>
Wed, 28 Feb 2024 22:24:09 +0100
changeset 13451 5c9df28a57bb
parent 13450 dba7073f1452
child 13452 93b4ce0115f0
net.server_epoll: Log failure to hook signals To make any such failures noticeable
net/server_epoll.lua
--- 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;