GNU bug report logs - #77629
[PATCH] services: tlp: Make destructor return #f on success.

Previous Next

Package: guix-patches;

Reported by: Nigko Yerden <nigko.yerden <at> gmail.com>

Date: Tue, 8 Apr 2025 06:44:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Nigko Yerden <nigko.yerden <at> gmail.com>
To: 77629 <at> debbugs.gnu.org
Cc: Nigko Yerden <nigko.yerden <at> gmail.com>
Subject: [bug#77629] [PATCH] services: tlp: Make destructor return #f on success.
Date: Tue,  8 Apr 2025 11:30:24 +0500
* gnu/services/pm.scm (tlp-shepherd-service): Make destructor
return #f on success. Destructor "should return #f if it is
now possible again to start the service at a later point"
(shepherd manual).

Change-Id: Ic0d21d32af158da1ae940d9c32c05a3471767764
---
Without this patch tlp service brings annoying messages "Service tlp might
have failed to stop" to the system log. Thanks to lfam and Rutherther on
IRC for mentioning in relation to other service that the destructor of a
shepherd service should return #f on success.

 gnu/services/pm.scm | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/gnu/services/pm.scm b/gnu/services/pm.scm
index e022437748..12f05b4b33 100644
--- a/gnu/services/pm.scm
+++ b/gnu/services/pm.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe <at> gmail.com>
 ;;; Copyright © 2024 Dariqq <dariqq <at> posteo.net>
 ;;; Copyright © 2024 Ian Eure <ian <at> retrospec.tv>
+;;; Copyright © 2025 Nigko Yerden <nigko.yerden <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -459,15 +460,17 @@ (define-configuration tlp-configuration
 (define (tlp-shepherd-service config)
   (let* ((tlp-bin (file-append
                    (tlp-configuration-tlp config) "/sbin/tlp"))
-         (tlp-action (lambda args
+         (tlp-action (lambda (return-value-on-success . args)
                        #~(lambda _
-                           (zero? (system* #$tlp-bin #$@args))))))
+                           (if (zero? (system* #$tlp-bin #$@args))
+                               #$return-value-on-success
+                               (not #$return-value-on-success))))))
     (list (shepherd-service
            (documentation "Run TLP script.")
            (provision '(tlp))
            (requirement '(user-processes))
-           (start (tlp-action "init" "start"))
-           (stop  (tlp-action "init" "stop"))))))
+           (start (tlp-action #t "init" "start"))
+           (stop  (tlp-action #f "init" "stop"))))))
 
 (define (tlp-activation config)
   (let* ((config-str (with-output-to-string

base-commit: c9524b5841a057b5e64abf0dca75261e741949c5
-- 
2.49.0





This bug report was last modified 96 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.