Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>spawn...() an overview of the eight spawn functions</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 spawn...()              An Overview of the Eight Spawn Functions

 spawn...(modeflag, pathname, arg-list | arg-array[,envp]);

    The eight spawn...() functions, like the exec...() functions, are
    used to load and execute a new program, or child process.  All
    require enough memory to load and execute the new process.

    The spawn...() functions differ from the functions in the exec family
    in only one way: They have an additional argument, 'modeflag'.  This
    argument specifies whether the parent process will be overlaid in
    memory by the child process (and thereby be destroyed), or be
    suspended until the child process terminates.  The first
    option--overlaying the parent in memory--is equivalent to the
    corresponding exec function.

    All eight of the spawn functions perform the same operation,
    differing only in the way arguments are passed, the use of the DOS
    PATH in searching for the program to be run ('pathname'), and in the
    use of the DOS environment. The eight functions offer various
    combinations of argument passing, use of the DOS PATH, and the
    environment:

                  Arguments to Child                         Passes New
                     Passed As            Searches DOS       Environment
    Function       List    Array         PATH for Child        String

    spawnl()         .
    spawnle()        .                                             .
    spawnlp()        .                          .
    spawnlpe()       .                          .                  .
    spawnv()                  .
    spawnve()                 .                                    .
    spawnvp()                 .                 .
    spawnvpe()                .                 .                  .


     Arguments:     Arguments are passed to the new process by including
                    one or more pointers to character strings in the
                    spawn() call. The character strings can be passed
                    either as a list of separate arguments, or as an
                    array of pointers. Spawn functions with an 'l' in
                    their name use the list method; functions with a 'v'
                    pass an array of pointers:

                    The spawn functions that use a list to pass arguments
                    to the child process are usually used when the number
                    of arguments is known in advance. In this case, the
                    first argument in the list is conventionally a
                    pointer to 'pathname', while the remaining arguments
                    in the list point to character strings that
                    constitute the argument list of the child process.
                    The last pointer must be NULL, to mark the end of the
                    list.

                    The spawn functions that use an array of pointers to
                    pass arguments to the child process are used when the
                    number of arguments is not known in advance. The
                    first pointer in the array usually points to
                    'pathname'; the last must be a NULL pointer.

          PATH:     If an explicit extension or period is given, the file
                    is searched for only as given.

                    If no extension is given, the file is first searched
                    for as given. If the file is not found, the extension
                    .COM is added and that file is searched for. If,
                    again, it is not found, .EXE is added and that file
                    is searched for.

                    The spawn functions with a 'p' in their name search
                    for 'pathname' in the current directory. If the file
                    is not found, the DOS PATH environment variable is
                    used.

   Environment:     Four of the spawn functions--spawnl, spawnlp, spawnv,
                    and spawnvp--allow the child process to inherit the
                    calling program's environment. The other four
                    functions (those with an 'e' at the end of their
                    name: spawnle, spawnlpe, spawnve, and spawnvpe) allow
                    the calling program to alter the called program's
                    environment by passing a list of environment settings
                    in the 'envp' argument.

    For details on using the spawn() functions, see the entry for the
    particular function that interests you.

   Portability:     MS-DOS only.


See Also: spawnl() spawnle() spawnv() spawnve() exec...()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson