- Spawn (computing)
Spawn is a function that loads and executes a new
child process in theMicrosoft Windows line ofoperating system s. The current process may or may not continue to execute asynchronously. Creating a new subprocess requires enough memory in which both the child process and the current program can execute.The spawn functions are inspired by
Unix functions fork and exec; however, as Windows does not support fork (at least in the Win32 API; POSIX emulation environments such as Cygwin or SFU do), the spawn function was supplied as a replacement for the fork-exec combination. However, the spawn function, although it deals adequately with the most common use cases, lacks the full power of fork-exec, since after fork any process settings which will survive an exec may be changed. However, in these cases, this deficiency can be made up for by using the more low-level CreateProcess API.Files that are open when a "spawn" call is made remain open in the child process.
In the "spawnl", "spawnlp", "spawnv", and "spawnvp" calls, the child process inherits the environment of the parent.
Prototype
:
int spawnl(int mode, char *path, char *arg0, ...);
:int spawnle(int mode, char *path, char *arg0, ..., char ** envp);
:int spawnlp(int mode, char *path, char *arg0, ...);
:int spawnlpe(int mode, char *path, char *arg0, ..., char ** envp);
:int spawnv(int mode, char *path, char **argv);
:int spawnve(int mode, char *path, char **argv, char ** envp);
:int spawnvp(int mode, char *path, char **argv);
:int spawnvpe(int mode, char *path, char **argv, char ** envp);
Function names
The base name of each function is spawn, followed by one or more letters:
References
ee also
Wikimedia Foundation. 2010.