[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 04/06: service: Add ‘start-command’.
From: |
Ludovic Courtès |
Subject: |
[shepherd] 04/06: service: Add ‘start-command’. |
Date: |
Wed, 20 Mar 2024 18:10:42 -0400 (EDT) |
civodul pushed a commit to branch wip-timers
in repository shepherd.
commit a801c2e087598985242108118cbb8109e7206c36
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Mar 18 22:27:14 2024 +0100
service: Add ‘start-command’.
This allows for race-free fork + waitpid, similar to
‘spawn-via-monitor’, but split-phase.
* modules/shepherd/service.scm (start-command): New procedure.
---
modules/shepherd/service.scm | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index b02587b..7ef2ff0 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -94,6 +94,7 @@
respawn-service
handle-SIGCHLD
with-process-monitor
+ start-command
spawn-command
spawn-shell-command
%precious-signals
@@ -2716,6 +2717,17 @@ context. The process monitoring fiber is responsible
for handling
@code{SIGCHLD} and generally dealing with process creation and termination."
(call-with-process-monitor (lambda () exp ...)))
+(define (start-command command . arguments)
+ "Start a process executing @var{command}, as per @code{fork+exec-command},
but
+immediately monitor its PID. Return two values: its PID and a channel on
+which its completion status will be sent."
+ (let ((reply (make-channel)))
+ (put-message (current-process-monitor)
+ `(spawn ,(cons command arguments) ,(current-service)
+ ,reply))
+ (values (unboxed-errors (get-message reply))
+ reply)))
+
(define (spawn-via-monitor arguments)
(let ((reply (make-channel)))
(put-message (current-process-monitor)
- [shepherd] branch wip-timers created (now 57786b0), Ludovic Courtès, 2024/03/20
- [shepherd] 01/06: build: Add support for Scheme tests., Ludovic Courtès, 2024/03/20
- [shepherd] 02/06: service: Fix typo in ‘register-logger’ message., Ludovic Courtès, 2024/03/20
- [shepherd] 04/06: service: Add ‘start-command’.,
Ludovic Courtès <=
- [shepherd] 03/06: service: ‘spawn-via-monitor’ associates a logger with the calling service., Ludovic Courtès, 2024/03/20
- [shepherd] 06/06: herd: Display information about timers., Ludovic Courtès, 2024/03/20
- [shepherd] 05/06: Add timer services., Ludovic Courtès, 2024/03/20