Bug 33335 - does anyone understand dbus-spawn.c?
Summary: does anyone understand dbus-spawn.c?
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: unspecified
Hardware: Other All
: medium enhancement
Assignee: Havoc Pennington
QA Contact: John (J5) Palmieri
URL:
Whiteboard:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2011-01-21 07:09 UTC by Simon McVittie
Modified: 2014-01-14 10:55 UTC (History)
4 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Simon McVittie 2011-01-21 07:09:03 UTC
On Bug #32992, Colin wrote:
> Stepping back a bit, does anyone have any idea what the heck is going on in
> dbus-spawn.c?  Why is there an "intermediate child between the main process and
> the grandchild"??  Why aren't we just executing the child directly?
> 
> The commit message doesn't say...

Meanwhile, the source code has this comment, dating back to Havoc's initial introduction of DBusBabysitter:

> /*
>  * I'm pretty sure this whole spawn file could be made simpler,
>  * if you thought about it a bit.
>  */

One thing that's particularly confusing is that there are three processes:

- the main process (typically dbus-daemon)
  - the "babysitter process"
    - the grandchild, which calls exec()

and in the main process, there's a DBusBabysitter object. Most of the comments, variable names, etc., say "the babysitter", so it's unclear whether they're talking about the DBusBabysitter object or the babysitter process.
Comment 1 Simon McVittie 2011-03-03 03:18:47 UTC
Back on Bug #32992, Colin wrote:
> Apparently this is a trick to avoid having the parent deal with SIGCHLD if it
> wasn't expecting it, see:
>
> http://compgroups.net/comp.unix.programmer/the-need-for-double-forking
Comment 2 Simon McVittie 2013-10-08 12:05:00 UTC
See also Attachment #74834 [details], Attachment #74836 [details], Attachment #74837 [details], Attachment #74839 [details] on Bug #60859 - in particular, the second of those documents why dbus-spawn looks like it does.
Comment 3 Simon McVittie 2014-01-14 10:55:42 UTC
Patches documenting this were merged.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.