civodul pushed a commit to branch main in repository shepherd. commit 2563bc01bec1a4b1e1c4d9be2e603b22a83aa171 Author: Ludovic Courtès <l...@gnu.org> AuthorDate: Mon Jan 1 23:33:07 2024 +0100
service: inetd: Clear O_NONBLOCK on the connection socket. Fixes a portability issue for GNU/Hurd. * modules/shepherd/service.scm (make-inetd-constructor): Add ‘fcntl’ calls before calling ‘spawn-child-service’. --- modules/shepherd/service.scm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm index 2b8c025..8eac844 100644 --- a/modules/shepherd/service.scm +++ b/modules/shepherd/service.scm @@ -2088,6 +2088,14 @@ rejecting connection from ~:[~a~;~*local process~].") (socket-address->string server-address) (= AF_UNIX (sockaddr:fam client-address)) (socket-address->string client-address)) + + ;; On the Hurd, the file descriptor returned by 'accept4' + ;; inherits O_NONBLOCK from SOCK. Clear it so the server + ;; gets a blocking socket (it doesn't hurt on Linux). + (fcntl connection F_SETFL + (logand (fcntl connection F_GETFL) + (lognot O_NONBLOCK))) + (spawn-child-service connection server-address client-address))))) (loop))))