Service activation and file descriptors

Havoc Pennington hp at redhat.com
Thu Jul 22 14:31:53 PDT 2004


On Thu, 2004-07-22 at 12:07, Philippe Laporte wrote:
> Hi,
>      About the preservation of file descriptors for launched services.
> 
> As far as I understand, the DBUS daemon redirects stderr and stdout to 
> /dev/null.
> 
> But suppose, you have a framework where all application/processes are 
> DBUS services, and that framework is started via the command-line. Then 
> one might be interested in having stdout and stderr go to that same 
> command line.
> 
> So how about this idea: Having an option so that before redirecting all 
> to /dev/null, the daemon should dup the stdout and stderr file 
> descriptors to somewhere, then when launching services, after the fork 
> but before the exec, dup the saved FDs back into FD 1 and 2 (stdout and 
> stderr).
> 
> How about it?

I think the solution may be simpler - for the per-session daemon, just
don't redirect to /dev/null, but for the system daemon continue to do
so. In short add a flag to the config file for this.

The reason for the /dev/null is that you don't want a system daemon to
be holding open an fd to some random NFS mount or something, or for that
matter printing things to some random place. For the session daemon, the
rest of the session will have the same stdout/stderr open anyhow so it's
harmless.

There is some possibility of funkiness (e.g. daemon is blocking on
stderr writing to a terminal while the terminal is trying to use the
daemon and so also blocking) but probably that won't happen.

Havoc




More information about the dbus mailing list