OSDN Git Service

* include/sched.h: Remove, overruled by newlib file.
[pf3gnuchains/sourceware.git] / winsup / cygwin / how-spawn-works.txt
1 (THIS DESCRIPTION IS OUT-OF-DATE)
2 Spawn.cc in cygwin handles spawn, vfork and exec calls. It does this via
3 a mode parameter that determines its behaviour with respect to the
4 child.
5
6 Of particular interest is the exec behaviour.
7
8 In general spawn_guts (where the action happens) does the following:
9 * Finds the actual program being run (which may include path searching).
10 * Determines the type (.exe, shell script, perl etc) and for non binary
11 programs finds the correct interpreter.
12 * Creates a commandline (based on the type and the user parameters).
13 * Guesses at whether the binary that will be invoked is a cygwin program
14 or not (if (real_path.iscygexec ())) and uses that information to copy
15 the argv table, or to translate it for win32 program usage.
16 * passes a handle to the parent to the child (note: this handle should
17 have it's rights restricted  the daemon is merged).
18 * Start the process.
19 * if the mode is _P_OVERLAY (we are doing an exec)
20 wait for the child to
21 a) if it's a cygwin process, signal us via an event.
22 b) if it's a win32 process, exit.
23 c) exit.
24
25 If a) occurs, we 'reparent' the child which makes it look to the current
26 process's parent in the pid and process group chains.
27 b) is where the cygwin process hangs around as a 'stub' presenting it's
28 pid as the win32 process's pid, to allow cygwin tools to kill the win32
29 process.
30 once a-c has occured, execution resumes.
31 * If the mode is _P_OVERLAY, this process exits, otherwise it's
32 behaviour depends on the mode parameter. See the last block of
33 spawn_guts.