dbus/test/spawn-test.c
Havoc Pennington 03b9ca6d4e 2003-04-04 Havoc Pennington <hp@redhat.com>
* dbus/dbus-spawn.c, dbus/dbus-spawn.h: Change dbus_spawn to
	return a "babysitter" object that is used to monitor the status of
	the spawned process and reap it when required.

	* test/test-segfault.c, test/test-exit.c,
	test/test-sleep-forever.c: binaries that do various lame things,
	used in the test suite.

	* dbus/dbus-sysdeps.c: kill _dbus_errno_to_string()
2003-04-05 00:37:17 +00:00

41 lines
809 B
C

#include <dbus/dbus.h>
#define DBUS_COMPILATION /* cheat and use dbus-sysdeps */
#include <dbus/dbus-sysdeps.h>
#include <dbus/dbus-spawn.h>
#undef DBUS_COMPILATION
#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, setup_func, NULL, &error))
{
fprintf (stderr, "Could not launch application: \"%s\"\n",
error.message);
}
return 0;
}