*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
+
+#include <config.h>
#include "dbus-launch.h"
#include <stdlib.h>
#include <ctype.h>
static pid_t bus_pid_to_kill = -1;
static void
-kill_bus()
+kill_bus(void)
{
verbose ("Killing message bus and exiting babysitter\n");
kill (bus_pid_to_kill, SIGTERM);
{
if (binary_syntax)
{
- write (1, bus_address, strlen (bus_address) + 1);
- write (1, &bus_pid, sizeof bus_pid);
- write (1, &bus_wid, sizeof bus_wid);
+ do_write (1, bus_address, strlen (bus_address) + 1);
+ do_write (1, &bus_pid, sizeof bus_pid);
+ do_write (1, &bus_wid, sizeof bus_wid);
return;
}
else if (c_shell_syntax)
{
switch (sig)
{
+#ifdef SIGHUP
case SIGHUP:
+#endif
+ case SIGINT:
case SIGTERM:
got_sighup = TRUE;
break;
act.sa_flags = 0;
sigaction (SIGHUP, &act, NULL);
sigaction (SIGTERM, &act, NULL);
+ sigaction (SIGINT, &act, NULL);
#ifdef DBUS_BUILD_X11
x11_init();
while (TRUE)
{
+#ifdef DBUS_BUILD_X11
+ /* Dump events on the floor, and let
+ * IO error handler run if we lose
+ * the X connection. It's important to
+ * run this before going into select() since
+ * we might have queued outgoing messages or
+ * events.
+ */
+ x11_handle_event ();
+#endif
+
FD_ZERO (&read_set);
FD_ZERO (&err_set);
FD_SET (x_fd, &read_set);
FD_SET (x_fd, &err_set);
}
-
+
select (MAX (tty_fd, x_fd) + 1,
&read_set, NULL, &err_set, NULL);
}
#ifdef DBUS_BUILD_X11
- /* Dump events on the floor, and let
- * IO error handler run if we lose
- * the X connection
+ /* Events will be processed before we select again
*/
if (x_fd >= 0)
verbose ("X fd condition reading = %d error = %d\n",
FD_ISSET (x_fd, &read_set),
FD_ISSET (x_fd, &err_set));
- x11_handle_event ();
#endif
if (tty_fd >= 0)
int binary_syntax,
int argc, char **argv, int remaining_args)
{
+ char *envvar = NULL;
+ char **args = NULL;
+
if (runprog)
{
- char *envvar;
- char **args;
int i;
envvar = malloc (strlen ("DBUS_SESSION_BUS_ADDRESS=") +
close (2);
exit (0);
oom:
+ if (envvar)
+ free (envvar);
+
+ if (args)
+ free (args);
+
fprintf (stderr, "Out of memory!");
exit (1);
}
fprintf (stderr, "Autolaunch requested, but X11 support not compiled in.\n"
"Cannot continue.\n");
exit (1);
-#else
+#else /* DBUS_BUILD_X11 */
+#ifndef DBUS_ENABLE_X11_AUTOLAUNCH
+ fprintf (stderr, "X11 autolaunch support disabled at compile time.\n");
+ exit (1);
+#else /* DBUS_ENABLE_X11_AUTOLAUNCH */
char *address;
pid_t pid;
long wid;
bourne_shell_syntax, binary_syntax, argc, argv, remaining_args);
exit (0);
}
+#endif /* DBUS_ENABLE_X11_AUTOLAUNCH */
}
- else if (read_machine_uuid_if_needed())
+ else if (read_machine_uuid_if_needed())
{
x11_init();
-#endif
+#endif /* DBUS_BUILD_X11 */
}
char write_pid_fd_as_string[MAX_FD_LEN];
char write_address_fd_as_string[MAX_FD_LEN];
+#ifdef DBUS_BUILD_X11
xdisplay = NULL;
+#endif
if (close_stderr)
do_close_stderr ();
close (bus_pid_to_launcher_pipe[READ_END]);
-#ifdef DBUS_BUILD_X11
+#ifdef DBUS_ENABLE_X11_AUTOLAUNCH
if (xdisplay != NULL)
{
verbose("Saving x11 address\n");