civodul pushed a commit to branch devel
in repository shepherd.

commit e5c986cb2e95549c60199ecc5f171dbcc1c726cc
Author: Ludovic Courtès <l...@gnu.org>
AuthorDate: Sat Aug 10 23:25:21 2024 +0200

    herd: Show PID and command on two separate lines.
    
    * modules/shepherd/scripts/herd.scm (display-service-status): Show PID
    and command of processes on two separate lines.
    * tests/basic.sh, tests/close-on-exec.sh, tests/daemonize.sh,
    tests/forking-service.sh, tests/inetd.sh, tests/pid-file.sh,
    tests/power-off.sh, tests/replacement.sh, tests/systemd.sh: Adjust grep
    and sed patterns accordingly.
---
 modules/shepherd/scripts/herd.scm | 7 ++++---
 tests/basic.sh                    | 2 +-
 tests/close-on-exec.sh            | 6 +++---
 tests/daemonize.sh                | 2 +-
 tests/forking-service.sh          | 2 +-
 tests/inetd.sh                    | 2 +-
 tests/pid-file.sh                 | 4 ++--
 tests/power-off.sh                | 2 +-
 tests/replacement.sh              | 2 +-
 tests/systemd.sh                  | 6 +++---
 10 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/modules/shepherd/scripts/herd.scm 
b/modules/shepherd/scripts/herd.scm
index a2c9253..1c3b1d5 100644
--- a/modules/shepherd/scripts/herd.scm
+++ b/modules/shepherd/scripts/herd.scm
@@ -395,9 +395,10 @@ calendar event."
        (('process ('version 0 _ ...)
                   ('id pid) ('command command) _ ...)
         ;; TRANSLATORS: "PID" is short for "process identifier" (Unix jargon).
-        ;; The string here looks like "PID 123 running: /bin/ntpd -x -y".
-        (format #t (l10n "  PID ~a running: ~a~%")
-                (highlight (number->string pid))
+        ;; The string here looks like "Main PID: 123".
+        (format #t (l10n "  Main PID: ~a~%")
+                (highlight (number->string pid)))
+        (format #t (l10n "  Command: ~a~%")
                 (shell-quoted-command command)))
        (('inetd-service ('version 0)
                         ('endpoints (('endpoint ('version 0)
diff --git a/tests/basic.sh b/tests/basic.sh
index 4ab7927..439ba52 100644
--- a/tests/basic.sh
+++ b/tests/basic.sh
@@ -88,7 +88,7 @@ pristine_status=`$herd status -n 0` # Prep for 'reload' test.
 echo $pristine_status | grep -E '(Start.*root|Stop.*test)'
 
 # This command should display shepherd's own PID.
-$herd status root | grep "PID $(cat "$pid")"
+$herd status root | grep "PID: $(cat "$pid")"
 
 # The "Recent messages" bit should contain that phrase.
 $herd status root | grep "Service root started"
diff --git a/tests/close-on-exec.sh b/tests/close-on-exec.sh
index c836d11..3f81f88 100644
--- a/tests/close-on-exec.sh
+++ b/tests/close-on-exec.sh
@@ -1,5 +1,5 @@
 # GNU Shepherd --- Ensure file descriptors are not leaked to children.
-# Copyright © 2022, 2023 Ludovic Courtès <l...@gnu.org>
+# Copyright © 2022-2024 Ludovic Courtès <l...@gnu.org>
 #
 # This file is part of the GNU Shepherd.
 #
@@ -154,8 +154,8 @@ test $(cat "$fd_count") -eq 4
 $herd start forkexec-ctor
 $herd status forkexec-ctor
 
-pid="$($herd status forkexec-ctor | grep "PID [0-9]\+ running" \
-  | sed -e's/^.* \([0-9]\+\) running.*$/\1/g')"
+pid="$($herd status forkexec-ctor | grep "PID: [0-9]\+" \
+  | sed -e's/^.* \([0-9]\+\)$/\1/g')"
 kill -0 "$pid"
 
 ls -l "/proc/$pid/fd"
diff --git a/tests/daemonize.sh b/tests/daemonize.sh
index 62e987f..86df442 100644
--- a/tests/daemonize.sh
+++ b/tests/daemonize.sh
@@ -65,7 +65,7 @@ until grep "Now running as process [0-9]" "$log"; do sleep 
0.2; done
 # This command should display shepherd's own PID, post-daemonize.
 new_pid="$($herd eval root '(getpid)' | tail -1)"
 kill -0 "$new_pid"
-$herd status root | grep "PID $new_pid"
+$herd status root | grep "PID: $new_pid"
 
 $herd status
 until $herd status a | grep running; do sleep 0.3; done
diff --git a/tests/forking-service.sh b/tests/forking-service.sh
index 6a529a1..4c2f5ee 100644
--- a/tests/forking-service.sh
+++ b/tests/forking-service.sh
@@ -175,7 +175,7 @@ done
 # Make sure 'herd stop' eventually terminates processes that ignore SIGTERM.
 $herd start test4
 $herd status test3 | grep running
-child_pid="$($herd status test4 | grep PID | sed '-es/.*PID \([0-9]\+\) 
running.*/\1/g')"
+child_pid="$($herd status test4 | grep PID | sed '-es/.*PID: 
\([0-9]\+\)$/\1/g')"
 kill -0 "$child_pid"
 $herd stop test3               # this will also stop 'test4'
 kill -0 "$child_pid" && false
diff --git a/tests/inetd.sh b/tests/inetd.sh
index 4fb6d2e..c9e76f9 100644
--- a/tests/inetd.sh
+++ b/tests/inetd.sh
@@ -133,7 +133,7 @@ guile -c "
 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 status test-inetd-1 | grep "Command:.*$SHELL.*echo hello"
 $herd stop test-inetd-1
 kill "$client_pid" || true
 $herd status test-inetd-1 && false
diff --git a/tests/pid-file.sh b/tests/pid-file.sh
index 3fff255..decf1f9 100644
--- a/tests/pid-file.sh
+++ b/tests/pid-file.sh
@@ -1,5 +1,5 @@
 # GNU Shepherd --- Test the #:pid-file option of 'make-forkexec-constructor'.
-# Copyright © 2016, 2019, 2020, 2022, 2023 Ludovic Courtès <l...@gnu.org>
+# Copyright © 2016, 2019-2020, 2022-2024 Ludovic Courtès <l...@gnu.org>
 #
 # This file is part of the GNU Shepherd.
 #
@@ -152,7 +152,7 @@ $herd status test-works | grep running
 test -f "$service_pid"
 kill -0 "`cat $service_pid`"
 known_pid="`$herd status test-works | grep PID \
-   | sed -es'/.*PID \([0-9]\+\) running.*$/\1/g'`"
+   | sed -es'/.*PID: \([0-9]\+\)$/\1/g'`"
 test `cat $service_pid` -eq $known_pid
 
 $herd stop test-works
diff --git a/tests/power-off.sh b/tests/power-off.sh
index ad8494a..23db106 100644
--- a/tests/power-off.sh
+++ b/tests/power-off.sh
@@ -55,7 +55,7 @@ $herd start b
 $herd status
 
 service_pid="`$herd status b | grep PID \
-   | sed -es'/.*PID \([0-9]\+\) running.*$/\1/g'`"
+   | sed -es'/.*PID: \([0-9]\+\)$/\1/g'`"
 kill -0 "$service_pid"
 
 # Now make sure the 'power-off' action works even in the face of a 'stop'
diff --git a/tests/replacement.sh b/tests/replacement.sh
index 6b8cf9c..0437972 100644
--- a/tests/replacement.sh
+++ b/tests/replacement.sh
@@ -107,7 +107,7 @@ $herd enable test
 $herd start test
 
 child_pid="$($herd status test | grep PID \
-   | sed '-es/.*PID \([0-9]\+\) running.*/\1/g')"
+   | sed '-es/.*PID: \([0-9]\+\)$/\1/g')"
 kill -0 "$child_pid"
 
 $herd stop test
diff --git a/tests/systemd.sh b/tests/systemd.sh
index b2d5a54..627c792 100644
--- a/tests/systemd.sh
+++ b/tests/systemd.sh
@@ -136,11 +136,11 @@ $herd start test-systemd-unix-eager
 $herd status test-systemd-unix-eager | grep running
 
 # The process should soon be running, before we've tried to connect to it.
-while ! $herd status test-systemd-unix-eager | grep -E "PID [0-9]+ running"
+while ! $herd status test-systemd-unix-eager | grep -E "PID: [0-9]+"
 do $herd status test-systemd-unix-eager; sleep 0.3; done
 
-child_pid="$($herd status test-systemd-unix-eager | grep PID \
-   | sed '-es/.*PID \([0-9]\+\) running.*/\1/g')"
+child_pid="$($herd status test-systemd-unix-eager | grep PID: \
+   | sed '-es/.*PID: \([0-9]\+\)$/\1/g')"
 kill -0 "$child_pid"
 converse_with_echo_server "(make-socket-address AF_UNIX \"$service_socket\")"
 while ! $herd status test-systemd-unix-eager | grep stopped

Reply via email to