2003-02-15 Anders Carlsson <andersca@codefactory.se>
[platform/upstream/dbus.git] / test / spawn-test.c
1 #include <dbus/dbus.h>
2
3 #define DBUS_COMPILATION /* cheat and use dbus-sysdeps */
4 #include <dbus/dbus-sysdeps.h>
5 #undef DBUS_COMPILATION
6 #include <stdio.h>
7
8 int
9 main (int argc, char **argv)
10 {
11   char **argv_copy;
12   int i;
13   DBusError error;
14   
15   if (argc < 2)
16     {
17       fprintf (stderr, "You need to specify a program to launch.\n");
18
19       return -1;
20     }
21
22   argv_copy = dbus_new (char *, argc);
23   for (i = 0; i < argc - 1; i++)
24     argv_copy [i] = argv[i + 1];
25   argv_copy[argc - 1] = NULL;
26   
27   if (!_dbus_spawn_async (argv_copy, &error))
28     {
29       fprintf (stderr, "Could not launch application: \"%s\"\n",
30                error.message);
31     }
32   
33   return 0;
34 }