Commit a644cad87d368ceb0d37398ae8cbb4d4093c9213

Thomas de Grivel 2024-09-10T19:16:03

daemonize before listening

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/lib/kc3/0.1/httpd.kc3 b/lib/kc3/0.1/httpd.kc3
index fb7ec6d..ad19859 100644
--- a/lib/kc3/0.1/httpd.kc3
+++ b/lib/kc3/0.1/httpd.kc3
@@ -75,13 +75,13 @@ defmodule HTTPd do
   def timeout = %Time{}
 
   def server = fn (host, port) {
+    daemonize()
     event_base = Event.base_new()
     socket = Socket.listen(host, port)
     puts("KC3 HTTPd: listening on #{host}:#{port}")
     acceptor_ev = Event.new(event_base, socket.fd, [:read, :persist],
                                  acceptor, void)
     r = Event.add(acceptor_ev, timeout)
-    daemonize()
     r = Event.dispatch(event_base)
     if r do
       e = errno()