dbus-daemon-1 --system seems to crash

Kay Sievers kay.sievers at vrfy.org
Thu Aug 5 17:54:31 PDT 2004


On Thu, Aug 05, 2004 at 12:44:28PM -0400, Havoc Pennington wrote:
> On Thu, 2004-08-05 at 05:01, Olivier Andrieu wrote:
> >  Havoc Pennington [Thu, 05 Aug 2004]:
> >  > On Wed, 2004-08-04 at 15:05, Kay Sievers wrote:
> >  > > Wouldn't it be nice to have a command line option instead, so the
> >  > > initscript can issue 'dbus-daemon-1 --system --fork' and it will
> >  > > always work? 'fork=yes|no' may also be a option to overwrite the
> >  > > one in the config file.
> >  > 
> >  > I like dbus-daemon-1 --system to just do everything, I don't think
> >  > there should have to be any magic in the initscripts. (Which is why
> >  > dbus-daemon also writes its own pid file, etc.)
> >  > 
> >  > I would suggest making a system.nofork.conf and use
> >  > --config-file=system.nofork.conf
> > 
> > Or we could turn the --fork option into a --nofork (prevent fork).
> 
> Adding a --nofork option would be fine with me.

Nice, here is it.

Thanks,
Kay
-------------- next part --------------
Index: bus/bus.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/bus.c,v
retrieving revision 1.53
diff -u -r1.53 bus.c
--- bus/bus.c	30 Jul 2004 05:59:33 -0000	1.53
+++ bus/bus.c	6 Aug 2004 00:48:30 -0000
@@ -540,7 +540,7 @@
 
 BusContext*
 bus_context_new (const DBusString *config_file,
-                 dbus_bool_t       force_fork,
+                 int               force_fork,
                  int               print_addr_fd,
                  int               print_pid_fd,
                  DBusError        *error)
@@ -659,7 +659,7 @@
     }
   
   /* Now become a daemon if appropriate */
-  if (force_fork || context->fork)
+  if ((force_fork != 0 && context->fork) || force_fork == 1)
     {
       DBusString u;
 
Index: bus/bus.h
===================================================================
RCS file: /cvs/dbus/dbus/bus/bus.h,v
retrieving revision 1.24
diff -u -r1.24 bus.h
--- bus/bus.h	30 Jul 2004 05:59:33 -0000	1.24
+++ bus/bus.h	6 Aug 2004 00:48:30 -0000
@@ -62,7 +62,7 @@
 } BusLimits;
 
 BusContext*       bus_context_new                                (const DBusString *config_file,
-                                                                  dbus_bool_t       force_fork,
+                                                                  int               force_fork,
                                                                   int               print_addr_fd,
                                                                   int               print_pid_fd,
                                                                   DBusError        *error);
Index: bus/main.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/main.c,v
retrieving revision 1.24
diff -u -r1.24 main.c
--- bus/main.c	30 Jul 2004 05:59:34 -0000	1.24
+++ bus/main.c	6 Aug 2004 00:48:30 -0000
@@ -62,7 +62,7 @@
 static void
 usage (void)
 {
-  fprintf (stderr, "dbus-daemon-1 [--version] [--session] [--system] [--config-file=FILE] [--print-address[=DESCRIPTOR]] [--print-pid[=DESCRIPTOR]] [--fork]\n");
+  fprintf (stderr, "dbus-daemon-1 [--version] [--session] [--system] [--config-file=FILE] [--print-address[=DESCRIPTOR]] [--print-pid[=DESCRIPTOR]] [--fork] [--nofork]\n");
   exit (1);
 }
 
@@ -200,8 +200,8 @@
   int i;
   dbus_bool_t print_address;
   dbus_bool_t print_pid;
-  dbus_bool_t force_fork;
-  
+  int force_fork;
+
   if (!_dbus_string_init (&config_file))
     return 1;
 
@@ -210,25 +210,27 @@
 
   if (!_dbus_string_init (&pid_fd))
     return 1;
-  
+
   print_address = FALSE;
   print_pid = FALSE;
-  force_fork = FALSE;
-  
+  force_fork = -1;
+
   prev_arg = NULL;
   i = 1;
   while (i < argc)
     {
       const char *arg = argv[i];
-      
+
       if (strcmp (arg, "--help") == 0 ||
           strcmp (arg, "-h") == 0 ||
           strcmp (arg, "-?") == 0)
         usage ();
       else if (strcmp (arg, "--version") == 0)
         version ();
+      else if (strcmp (arg, "--nofork") == 0)
+        force_fork = 0;
       else if (strcmp (arg, "--fork") == 0)
-        force_fork = TRUE;
+        force_fork = 1;
       else if (strcmp (arg, "--system") == 0)
         {
           check_two_config_files (&config_file, "system");


More information about the dbus mailing list