Re: gspawn(-win32): why helper?




On Nov 24, 2006, at 2:29 PM, Felix Kater wrote:

when glib spawns processes it starts a helper process first which
itself then starts the wanted process.

I've studied the gspawn(-win32).c and the win32 helper code, too,
however, I simply don't understand the need of the helper process. :-/

This comment, at the top of gspawn-win32.c, says that it's basically because win32 sucks. Er, i mean, because win32 doesn't have a proper fork().

/*
* Implementation details on Win32.
*
* - There is no way to set the no-inherit flag for
*   a "file descriptor" in the MS C runtime. The flag is there,
*   and the dospawn() function uses it, but unfortunately
*   this flag can only be set when opening the file.
* - As there is no fork(), we cannot reliably change directory
*   before starting the child process. (There might be several threads
*   running, and the current directory is common for all threads.)
*
* Thus, we must in most cases use a helper program to handle closing
* of (inherited) file descriptors and changing of directory. The
* helper process is also needed if the standard input, standard
* output, or standard error of the process to be run are supposed to
* be redirected somewhere.
*
* The structure of the source code in this file is a mess, I know.
*/


The simple tests you mentioned don't involve changing directories or inheriting file descriptors.



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