dbus/test/spawn-test.c
Chengwei Yang ec6ea1a6a8 DBusBabysitter: change executable to log_name
DBusBabysitter->executable is defined as executable name to use in error
messages. However, if servicehelper used, then the executable name is
servicehelper. It's not much help because we couldn't figure out which
service we're trying to activated if error happens.

In the following patch, we'll use service name to be activated as the
child log identifier and add a parameter to
_dbus_spawn_async_with_babysitter() to pass the log identifier.  Since
this is not the case in test, so executable changed to log_name.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68559
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-11-01 12:40:41 +00:00

42 lines
791 B
C

#include <config.h>
#include <dbus/dbus.h>
#include <dbus/dbus-sysdeps.h>
#include <dbus/dbus-spawn.h>
#include <stdio.h>
static void
setup_func (void *data)
{
printf ("entering setup func.\n");
}
int
main (int argc, char **argv)
{
char **argv_copy;
int i;
DBusError error;
if (argc < 2)
{
fprintf (stderr, "You need to specify a program to launch.\n");
return -1;
}
argv_copy = dbus_new (char *, argc);
for (i = 0; i < argc - 1; i++)
argv_copy [i] = argv[i + 1];
argv_copy[argc - 1] = NULL;
if (!_dbus_spawn_async_with_babysitter (NULL, argv_copy[0], argv_copy, NULL, setup_func, NULL, &error))
{
fprintf (stderr, "Could not launch application: \"%s\"\n",
error.message);
}
dbus_free(argv_copy);
return 0;
}