g_spawn_async_with_pipes and WIN32



Hello!

I'm having trouble reading the stdout pipe from
g_spawn_async_with_pipes() when compiled for WIN32. The docs on
developer.gnome.org mention some differences in Windows behavior but
nothing mentions what I'm supposed to read the pipe with. I've googled
endlessly and so far failed to produce the magic combination of search
terms to solve my problem.

So far (greatly trimmed for simplicity):

gint out;
if
(g_spawn_async_with_pipes(0,argv,0,G_SPAWN_DO_NOT_REAP_CHILD,0,0,&pid,0,&out,0,&error)) {
#ifdef WIN32
    WaitForSingleObject(pid,INFINITE);
    len = _read(out,buf,10);
    _close(out);
#else
    waitpid(pid,&result,0);
    len = read(out,buf,10);
    close(out);
#endif
}

The process being called simply prints a short message and returns. I
see the message if I execute the program from a command prompt under
Windows. The linux version works, In the Windows version, _read() always
returns -1, errno=EBADF.

I tried ReadFile(), which required casting out to a HANDLE, but that
call never returns. I must be doing something terribly wrong, since I
hardly believe that it doesn't work at all.

So I guess my real question is, under WIN32, how do I read the stdout
pipe returned from g_spawn_async_with_pipes()?





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