#include int main (int argc, char ** argv) { GdkDisplay *display; GdkScreen *screen; const gchar *command; gint num_screen; gchar **my_argv = NULL; GPid pid; GError *error = NULL; if (argc != 3) return 1; command = argv[1]; num_screen = atoi (argv[2]); gtk_init (&argc, &argv); display = gdk_display_get_default (); screen = gdk_display_get_screen (display, num_screen); my_argv = g_new (char *, 2); my_argv[0] = g_strdup (command); my_argv[1] = NULL; if (gdk_spawn_on_screen (screen, "/tmp", my_argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &pid, &error)) fprintf (stderr, "PID = %d\n", pid); else fprintf (stderr, "%s\n", error->message); g_strfreev (my_argv); return 0; }