summaryrefslogtreecommitdiffstats
path: root/test/spawn-test.c
blob: fda0309b6fea7f0a663494000fe4ae85a0ed934a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <dbus/dbus.h>

#define DBUS_COMPILATION /* cheat and use dbus-sysdeps */
#include <dbus/dbus-sysdeps.h>
#undef DBUS_COMPILATION
#include <stdio.h>

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 (argv_copy, &error))
    {
      fprintf (stderr, "Could not launch application: \"%s\"\n",
	       error.message);
    }
  
  return 0;
}