


      SPAWN(2)                   (Bull-SPS9)                   SPAWN(2)



      NAME
           spawnl, spawnv, spawnle, spawnve, spawnlp, spawnvp - spawn a
           process

      SYNTAX
           int spawnl (path, arg0, arg1, ..., argn, 0)
           char *path, *arg0, *arg1, ..., *argn;

           int spawnv (path, argv)
           char *path, *argv[ ];

           int spawnle (path, arg0, arg1, ..., argn, 0, envp)
           char *path, *arg0, *arg1, ..., *argn, *envp[ ];

           int spawnve (path, argv, envp)
           char *path, *argv[ ], *envp[ ];

           int spawnveq (path, argv, envp, links, queues, msgs, pages)
           char *path, *argv[ ], *envp[ ];
           int links, queues, msgs, pages;

           int spawnlp (file, arg0, arg1, ..., argn, 0)
           char *file, *arg0, *arg1, ..., *argn;

           int spawnvp (file, argv)
           char *file, *argv[ ];

      DESCRIPTION
           Spawn creates a new process. The new process is constructed
           from an ordinary, executable file called the "new process
           file" consisting of a header (see a.out (4)), a text
           segment, and a data segment. The data segment contains an
           initialized portion and an uninitialized portion (bss).

           Spawn is the exact equivalent of a combination of fork(2)
           and exec(2), but executes faster.  Spawnveq is a special
           implementation of spawn corresponding to gfork(2) and
           exec(2).

           When a C program is executed, it is called as follows:

                main (argc, argv, envp)
                int argc;
                char **argv, **envp;

           where argc is the argument count and argv is an array of
           character pointers to the arguments themselves. As
           indicated, argc is conventionally at least one and the first
           member of the array points to a string containing the name
           of the file.

           Path points to a path name that identifies the new process



      Page 1                                         (73 A2 02MTA REV1)






      SPAWN(2)                   (Bull-SPS9)                   SPAWN(2)



           file.

           File points to the new process file. The path prefix for
           this file is obtained by a search of the directories passed
           as the environment line "PATH =" (see environ(5)).  The
           environment is supplied by the shell (see sh(1)).

           Arg0, arg1, ..., argn are pointers to null-terminated
           character strings. These strings constitute the argument
           list available to the new process. By convention, at least
           arg0 must be present and point to a string that is the same
           as path (or its last component).

           Argv is an array of character pointers to null-terminated
           strings. These strings constitute the argument list
           available to the new process. By convention, argv must have
           at least one member, and it must point to a string that is
           the same as path (or its last component). Argv is terminated
           by a null pointer.

           Envp is an array of character pointers to null-terminated
           strings. These strings constitute the environment for the
           new process.  Envp is terminated by a null pointer. For
           spawnl and spawnv, the C run-time start-off routine places a
           pointer to the calling process's environment in the global
           cell:
                extern char **environ;
           and it is used to pass the calling process's environment to
           the new process.

           File descriptors open in the calling process remain open in
           the new process, except for those whose close-on-exec flag
           is set; see fcntl(2).  For those file descriptors that
           remain open, the file pointer is unchanged.

           Signals set to terminate the calling process will be set to
           terminate the new process.  Signals set to be ignored by the
           calling process will be set to be ignored by the new
           process.  Signals set to be caught by the calling process
           will be set to terminate new process; see signal(2).

           If the set-user-ID mode bit of the new process file is set
           (see chmod(2)), spawn sets the effective user ID of the new
           process to the owner ID of the new process file.  Similarly,
           if the set-group-ID mode bit of the new process file is set,
           the effective group ID of the new process is set to the
           group ID of the new process file.  The real user ID and real
           group ID of the new process remain the same as those of the
           calling process.

           The new process also inherits the following attributes from
           the calling process:



      Page 2                                         (73 A2 02MTA REV1)






      SPAWN(2)                   (Bull-SPS9)                   SPAWN(2)



                parent process ID
                process group ID
                tty group ID (see exit(2) and signal(2))
                current working directory
                root directory
                file mode creation mask (see umask(2))
                utime, stime, cutime, and cstime (see times(2))

           Spawn will fail and return to the calling process if one or
           more of the following are true:

                The system limit on the number of executing processes,
                or the limit on the number of executing processes for
                one user, is exceeded.  [EAGAIN]

                One or more components of the new process file's path
                name do not exist.  [ENOENT]

                A component of the new process file's path prefix is
                not a directory.  [ENOTDIR]

                Search permission is denied for a directory listed in
                the new process file's path prefix.  [EACCES]

                The new process file is not an ordinary file.  [EACCES]

                The new process file mode denies execution permission.
                [EACCES]

                The spawn is not an spawnlp or spawnvp, and the new
                process file has the appropriate access permission but
                an invalid magic number in its header.  [ENOEXEC]

                The new process file is a pure procedure (shared text)
                file that is currently open for writing by some
                process.  [ETXTBSY]

                The new process requires more memory than is allowed by
                the system-imposed maximum MAXMEM.  [ENOMEM]

                The number of bytes in either the new process's
                argument list or the new environment is greater than
                the system-imposed limit of >4092 bytes.  [E2IG]

                The new process file is not as long as indicated by the
                size values in its header.  [EFAULT]

                Path, argv, or envp point to an illegal address.
                [EFAULT]

      RETURN VALUE
           If an error occurs, spawn returns -1 to the calling process



      Page 3                                         (73 A2 02MTA REV1)






      SPAWN(2)                   (Bull-SPS9)                   SPAWN(2)



           and the errno will be set to indicate the error.  If
           successful, spawn returns the process ID of the new process,
           and errno is set to zero.

      SEE ALSO
           exec(2), exit(2), fork(2), environ(5).

















































      Page 4                                         (73 A2 02MTA REV1)



