Subject: Re: [bug#30498] [WIP v2 shepherd] shepherd: If /dev/kmsg is writable, use it for logging.

From: [email-masked] (Ludovic Courtès)
Date: Tue, 27 Feb 2018 10:19:47 +0100

Hi Danny,

Danny Milosavljevic <[email-masked]> skribis:

>> As for cryptsetup, what if the service that runs crypsetup simply
>> parameterizes ‘log-output-port’ to /dev/console?  That would give us the
>> current behavior, right?
>
> I don't understand why this current-output-port stuff is somehow passed on to
> forked processes in the first place (why does cryptsetup care what I do
> to guile variables?).
>
> scheme@(guile-user)> (current-output-port (%make-void-port "w"))
> scheme@(guile-user)> (system* "ls" "/")
> scheme@(guile-user)>

Funny no?  :-)

This is in libguile/posix.c, ‘scm_open_process’ and ‘start_child’: when
the current input/output/error port isn’t a file port, FDs 0/1/2 in the
child are made to point to /dev/null.  Otherwise, they are inherited as
file descriptors.

For cryptsetup, this should be what we want if we do:

  (call-with-output-file "/dev/console"
    (lambda (port)
      (parameterize ((log-output-port port)
                     (current-input-port port)
                     (current-error-port port))
        (invoke "cryptsetup" …))))

Or do we even need to care about ‘log-output-port’?  Thoughts?

> It wasn't my intention to inherit them as file descriptors... also, for guile
> buffering ports, how does it inherit those as file descriptors?  Will it still
> do the custom line buffering that shepherd does, also when a child process
> writes there?

Shepherd does not process the stdout/err of child processes in any way,
so there shouldn’t be buffering there.

Ludo’.