Subject: bug#76343: shepherd 1.0.2 --help: warning: call to environ while multiple threads are running; further behavior unspecified.

From: Simon Josefsson <[email-masked]>
Date: Tue, 04 Mar 2025 17:20:03 +0100

Ludovic Courtès <[email-masked]> writes:

> Hi,
>
> Simon Josefsson <[email-masked]> skribis:
>
>> A shephard-specific patch would be the simplest at this point, I think.
>>  
>> Do you have some idea how to do that?  I agree it seems like a Debian-
>> specific patch for now.
>
> The patch below appears to do the trick.  I guess I could just as well
> integrate it in the next 1.0.x bug-release.
>
> Does it work for you?

It does, yes!

Breaking: https://salsa.debian.org/debian/shepherd/-/jobs/7197263
Working: https://salsa.debian.org/debian/shepherd/-/jobs/7197290

The only difference is your patch.  I'll upload this eventually.

Thanks,
/Simon

>
> Thanks,
> Ludo’.
>
> diff --git a/modules/shepherd.scm b/modules/shepherd.scm
> index d55373a..a35a415 100644
> --- a/modules/shepherd.scm
> +++ b/modules/shepherd.scm
> @@ -515,7 +515,11 @@ fork in the child process."
>                           ;; stdout.  Redirect stdout to the bitbucket so we
>                           ;; don't log twice.
>                           (%make-void-port "w")
> -                         (current-output-port)))))
> +                         (current-output-port))))
> +
> +                   ;; In Guile 3.0.10, calling 'environ' from the top-level
> +                   ;; triggers a warning so do it from here.
> +                   (default-environment-variables (environ)))
>  
>        (parameterize ((current-output-port (%current-service-output-port)))
>          (set-port-encoding! (log-output-port) "UTF-8")
> diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
> index 2d64897..c8667e6 100644
> --- a/modules/shepherd/service.scm
> +++ b/modules/shepherd/service.scm
> @@ -1437,7 +1437,7 @@ background:~{ ~a~}."
>  (define default-environment-variables
>    ;; The default list of environment variable name/value pairs that should be
>    ;; set when starting a service.
> -  (make-parameter (environ)))
> +  (make-parameter '()))
>  
>  (define default-pid-file-timeout
>    ;; Maximum number of seconds to wait for a PID file to show up.
>