Merge "Optional autogen.sh flag --enable-kdbus-transport added allowing to compile...
[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;
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, NULL, setup_func, NULL, &error))
34     {
35       fprintf (stderr, "Could not launch application: \"%s\"\n",
36                error.message);
37     }
38
39   dbus_free(argv_copy);
40  
41   return 0;
42 }