spawn-test.c 791 Bytes
Newer Older
1
#include <config.h>
2 3 4
#include <dbus/dbus.h>

#include <dbus/dbus-sysdeps.h>
5
#include <dbus/dbus-spawn.h>
6 7
#include <stdio.h>

8 9 10 11 12 13
static void
setup_func (void *data)
{
  printf ("entering setup func.\n");
}

14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
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;
  
33
  if (!_dbus_spawn_async_with_babysitter (NULL, argv_copy[0], argv_copy, NULL, setup_func, NULL, &error))
34 35 36 37
    {
      fprintf (stderr, "Could not launch application: \"%s\"\n",
	       error.message);
    }
Ralf Habacker's avatar
Ralf Habacker committed
38 39 40

  dbus_free(argv_copy);
 
41 42
  return 0;
}