cmake: Add X11 include path for tools
[platform/upstream/dbus.git] / test / spawn-test.c
1 #include <config.h>
2 #include <dbus/dbus.h>
3
4 #include <dbus/dbus-sysdeps.h>
5 #include <dbus/dbus-spawn.h>
6 #include <stdio.h>
7
8 static void
9 setup_func (void *data)
10 {
11   printf ("entering setup func.\n");
12 }
13
14 int
15 main (int argc, char **argv)
16 {
17   char **argv_copy;
18   int i;
19   DBusError error = DBUS_ERROR_INIT;
20   
21   if (argc < 2)
22     {
23       fprintf (stderr, "You need to specify a program to launch.\n");
24
25       return -1;
26     }
27
28   argv_copy = dbus_new (char *, argc);
29   for (i = 0; i < argc - 1; i++)
30     argv_copy [i] = argv[i + 1];
31   argv_copy[argc - 1] = NULL;
32   
33   if (!_dbus_spawn_async_with_babysitter (NULL, argv_copy[0], argv_copy, NULL,
34                                           DBUS_SPAWN_NONE, setup_func, NULL,
35                                           &error))
36     {
37       fprintf (stderr, "Could not launch application: \"%s\"\n",
38                error.message);
39     }
40
41   dbus_free(argv_copy);
42  
43   return 0;
44 }