guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[shepherd] 03/08: service: ‘make-inetd-forkexec-constructor’ returns a <


From: Ludovic Courtès
Subject: [shepherd] 03/08: service: ‘make-inetd-forkexec-constructor’ returns a <process>.
Date: Sat, 17 Feb 2024 13:07:18 -0500 (EST)

civodul pushed a commit to branch devel
in repository shepherd.

commit 23c50d17bec51680460084d704d143d735354fda
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sat Feb 17 17:39:43 2024 +0100

    service: ‘make-inetd-forkexec-constructor’ returns a <process>.
    
    This is a followup to 4e3b58e5cdc3fd3c0448f631fc4983224aafc347.
    
    * modules/shepherd/service.scm (make-inetd-forkexec-constructor): Return
    a <process> record instead of a PID.
    * tests/inetd.sh: Test it.
---
 modules/shepherd/service.scm |  2 +-
 tests/inetd.sh               | 19 +++++++++++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 12700b8..3cfcf75 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -2160,7 +2160,7 @@ thrown an previously-opened sockets are closed."
                             #:resource-limits resource-limits))
             (begin
               (close-port connection)
-              pid))))))
+              (process pid command)))))))
 
 (define (socket-address->string address)
   "Return a human-readable representation of ADDRESS, an object as returned by
diff --git a/tests/inetd.sh b/tests/inetd.sh
index 2affb71..00f89e6 100644
--- a/tests/inetd.sh
+++ b/tests/inetd.sh
@@ -1,5 +1,5 @@
 # GNU Shepherd --- Test transient services.
-# Copyright © 2022, 2023 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2022-2024 Ludovic Courtès <ludo@gnu.org>
 #
 # This file is part of the GNU Shepherd.
 #
@@ -47,7 +47,8 @@ cat > "$conf" <<EOF
                                     (endpoint (make-socket-address
                                                AF_INET
                                                INADDR_LOOPBACK
-                                               $PORT))))
+                                               $PORT)))
+                                    #:service-name-stem "test-inetd")
     #:stop  (make-inetd-destructor))
   (service
     '(test-inetd6)
@@ -119,6 +120,20 @@ converse_with_echo_server ()
       (match (read-line sock) (\"done\" #t))"
 }
 
+# Initiate a conversation and make sure it creates a transient service with
+# correct process information.
+guile -c "
+  (define address (make-socket-address AF_INET INADDR_LOOPBACK $PORT))
+  (define sock (socket (sockaddr:fam address) SOCK_STREAM 0))
+  (connect sock address)
+  (sleep 300)" &
+client_pid=$!
+$herd status test-inetd-1
+$herd status test-inetd-1 | grep transient
+$herd status test-inetd-1 | grep "PID.*$SHELL.*echo hello"
+$herd stop test-inetd-1
+kill "$client_pid" || true
+$herd status test-inetd-1 && false
 
 for i in $(seq 1 3)
 do



reply via email to

[Prev in Thread] Current Thread [Next in Thread]