civodul pushed a commit to branch devel in repository shepherd. commit 3a227793b88225e15a6a2e699932bd21c57884e9 Author: Ludovic Courtès <l...@gnu.org> AuthorDate: Sun Aug 11 15:31:08 2024 +0200
timer: Add #:termination-signal. * modules/shepherd/service/timer.scm (make-timer-constructor): Add #:termination-signal and pass it in ‘terminate-process’ calls. * doc/shepherd.texi (Timers): Document it. --- doc/shepherd.texi | 3 ++- modules/shepherd/service/timer.scm | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/shepherd.texi b/doc/shepherd.texi index a02ca1e..6051ffa 100644 --- a/doc/shepherd.texi +++ b/doc/shepherd.texi @@ -1538,7 +1538,8 @@ instances running concurrently. When @var{max-duration} is true, it is the maximum duration in seconds that a run may last, provided @var{action} is a command. Past @var{max-duration} -seconds, the timer's process is forcefully terminated. +seconds, the timer's process is forcefully terminated with signal +@var{termination-signal}. @end deffn @deffn {Procedure} make-timer-destructor diff --git a/modules/shepherd/service/timer.scm b/modules/shepherd/service/timer.scm index be40446..e4085e8 100644 --- a/modules/shepherd/service/timer.scm +++ b/modules/shepherd/service/timer.scm @@ -583,6 +583,7 @@ list, to be executed as @var{user} and @var{group}, with the given (define* (make-timer-constructor event action #:key log-file max-duration + (termination-signal SIGTERM) wait-for-termination?) "Return a procedure for use as the @code{start} method of a service. The procedure will perform @var{action} at every occurrence of @code{event}, a @@ -600,7 +601,8 @@ instances running concurrently. When @var{max-duration} is true, it is the maximum duration in seconds that a run may last, provided @var{action} is a command. Past @var{max-duration} -seconds, the timer's process is forcefully terminated." +seconds, the timer's process is forcefully terminated with signal +@var{termination-signal}." (lambda () (let ((channel (make-channel)) (name (service-canonical-name (current-service)))) @@ -624,7 +626,7 @@ seconds, the timer's process is forcefully terminated." name (length processes)) (for-each (match-lambda ((pid . _) - (terminate-process pid SIGHUP))) + (terminate-process pid termination-signal))) processes) ;; If there are processes left, keep going until they're gone. (if (pair? processes) @@ -676,7 +678,7 @@ after ~a seconds.") (local-output (l10n "Terminating \ process ~a of timer '~a' after maximum duration of ~a seconds.") pid name max-duration) - (terminate-process pid SIGTERM) + (terminate-process pid termination-signal) (get-message status)) (result result))