Re: Why g_spawn_async return a null pid under Windows?



I think that you need to pass the G_SPAWN_DO_NOT_REAP_CHILD flag. On
Win32, g_spawn_async() won't return the PID otherwise. If you don't
pass that flag, the pid you get back would be pretty meaningless, as
glib may have already reaped it.

Also, this list of more for the development of GTK+ and Glib
themselves. In the future, you should post questions like this to the
gtk-app-devel list.

Cheers,
Dom

2008/7/24 gege2061 <gege2061 redaction-developpez com>:
> Hi,
>
> I have a small program that spawn process with g_spawn_async, but the
> returned GPid is NULL. I works under Windows (I don't have this problem
> under Linux).
>
> -----
> #include <glib.h>
>
> int main (void)
> {
>  GPid pid;
>  GError *error = NULL;
>  gchar *argv[] = {"test.exe", NULL};
>
>  if (g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &pid,
>                     &error))
>  {
>    g_print ("%p\n", pid);
>  }
>  else
>  {
>    g_print (error->message);
>    g_error_free (error), error = NULL;
>  }
>  return 0;
> }
> -----
>
> The process is launched with the _wspawnvp function and the GPid is an
> intptr_t, isn't it?
>
> Thank's in advance.
>
> Best regards.
>
> --
> Nicolas Joseph
>
> Responsable de la rubrique GTK+ de developpez.com /
> In charge of the GTK+ section on developpez.com
>
> http://nicolasj.developpez.com
>
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-devel-list
>
>



-- 
Counting bodies like sheep to the rhythm of the war drums.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]