Subject: Re: bug#39708: nfs-service-type broken: rpc.mountd respawns too quickly

From: Maxim Cournoyer <[email-masked]>
Date: Sun, 08 Mar 2020 00:39:57 -0500

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

> Hi,
>
> Maxim Cournoyer <[email-masked]> skribis:
>
>> The rpc.mountd service, one of the required services for
>> nfs-service-type, respawns the process quickly until disabled.
>
> Does /var/log/messages contain hints?  Is rpc.statd running?
> Could it be that all these services need to depend on ‘loopback’?
>
> No answers, but a lot of questions.  :-)
>
> Ludo’.

OK, I've managed to find the problem.  rpc.mountd daemonizes itself upon
starting by default, which is not supported by Shepherd (at least not
its `make-forkexec-constructor' procedure).  I had to pass the
'--foreground' option to workaround this limitation (c.f.: commit
5fdc5b2d57d2e7ab04dbaf9c85e7f34eebe81495).

It'd be interesting to see what systemd does when a service is hinted as
forking in its configuration file.  We should also document that
limitation in the Shepherd info manual (see attached patch for
Shepherd).

Maxim
From 8f84ce9abe12b49340befbeee663896d226bb869 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Sun, 8 Mar 2020 00:34:36 -0500
Subject: [PATCH] doc: Note that make-forkexec-constructor requires a
 non-forking process.

This merits to be documented as it can be confusing, as demonstrated by
<https://bugs.gnu.org/39708>.
---
 doc/shepherd.texi | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/doc/shepherd.texi b/doc/shepherd.texi
index fbd1a3f..a0ac11b 100644
--- a/doc/shepherd.texi
+++ b/doc/shepherd.texi
@@ -898,12 +898,14 @@ execution of the @var{command} was successful, @code{#t} if not.
   [#:directory (default-service-directory)] @
   [#:environment-variables (default-environment-variables)]
 Return a procedure that forks a child process, closes all file
-descriptors except the standard output and standard error descriptors, sets
-the current directory to @var{directory}, changes the environment to
-@var{environment-variables} (using the @code{environ} procedure), sets the
-current user to @var{user} and the current group to @var{group} unless they
-are @code{#f}, and executes @var{command} (a list of strings.)  The result of
-the procedure will be the PID of the child process.
+descriptors except the standard output and standard error descriptors,
+sets the current directory to @var{directory}, changes the environment
+to @var{environment-variables} (using the @code{environ} procedure),
+sets the current user to @var{user} and the current group to @var{group}
+unless they are @code{#f}, and executes @var{command} (a list of
+strings.)  The result of the procedure will be the PID of the child
+process.  The child process must not fork (daemonize) itself for this to
+work correctly.
 
 When @var{pid-file} is true, it must be the name of a PID file
 associated with the process being launched; the return value is the PID
-- 
2.25.0