yelninei--- via Bug reports for GNU Guix <[email protected]> writes:

> After mentioning this on IRC Ludovic pushed 
> 8d31cafbdcb818160852a5d1e6fc24c1a9c53e41 to the shepherd repo.
>
> I wanted to try this out and reconfigured using the shepherd from this commit 
> as pid1 in the vm (a bit tricky because of help2man).
>
> The first connection still fails in the same way.unexpected build daemon 
> error: reading from file: Resource temporarily unavailable

I looked a bit into this, and I think shepherd is doing the right
working as expected, making the socket blocking before executing
guix-daemon (it’s clear when stracing it on Linux).

So there must be something specific at play on the Hurd.

I tried this snippet (server on one side, client on the other side) and
it works as expected: ‘accept’ blocks and subsequent read does not get
EAGAIN.

So I’m at loss here.  Does ‘tests/systemd.sh’ succeed when ran natively?
(In particular the check added in
8d31cafbdcb818160852a5d1e6fc24c1a9c53e41.)

Thanks,
Ludo’.

(use-modules (ice-9 match))

(define (blocking-port port)
  "Return PORT after putting it in non-blocking mode."
  (let ((flags (fcntl port F_GETFL)))
    (fcntl port F_SETFL (logand (lognot O_NONBLOCK) flags))
    port))

(let ((sock (socket AF_UNIX (logior SOCK_STREAM SOCK_NONBLOCK) 0)))
  (bind sock AF_UNIX "/tmp/sock")
  (listen sock 10)
  (match (pk 'x (accept (blocking-port sock) SOCK_CLOEXEC)) ;should block
    ((port . _)
     (pk 'read (read port)))))

;; Client:
(let ((sock (socket AF_UNIX (logior SOCK_STREAM) 0)))
  (connect sock AF_UNIX "/tmp/sock")
  (display "hi!\n" sock))

Reply via email to