g_spawn_async in win32
- From: "r" <alblas3 xs4all nl>
- To: "gtk-list gnome org" <gtk-list gnome org>
- Subject: g_spawn_async in win32
- Date: Mon, 29 Jun 2009 03:53:17 +0200 (CEST)
Hi,
I have a gtk program doing now and then a calculation taking a few secs.
To prevent freezing my appl. I want to use for Linux g_thread.
However, this is not supported for Windows in combination  with gtk.
As far as I know the only possibility to solve this for Windows is using
an external program and call this by g_spawn_async. (Not a nice method; is
there another way?)
As far as I know g_spawn_async should work under Windows, but I can't get
it to work.
Below a test program; it works fine under Linux, but g_spawn_async returns
always FALSE under Windows.
(In this example g_spawn_async opens nedit. Note that the (now commented
out) 'system' call does work.)
(glib version is 2.16.3.)
#include "gtk/gtk.h"
static void post_process(GPid pid,int status,gpointer data)
{
  // ext. program did end
  puts("post_process");
}
main(int argc,char **argv)
{
  char *sargv[2];
  GPid pid=0;
  gtk_init(&argc,&argv);
  sargv[0]="nedit";
  sargv[1]=NULL;
//system(sargv[0]);
  if (g_spawn_async(NULL,sargv,NULL,
                    G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
                    NULL,
                    NULL,&pid,NULL))
  {
    g_child_watch_add(pid,(GChildWatchFunc)post_process,NULL);
    gtk_main();
  }
  else
  {
    puts("ERROR!");
  }
}
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]