| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

process_create_full

#include "sflproc.h"
PROCESS
process_create_full (PROCESS_DATA *procinfo)

Synopsis

Creates a subprocess and returns a PROCESS identifying the new process. Optionally redirects standard input, output, error file handles to supplied file handles, changes working directory, and environment. In some operating systems can also optinally change the root directory (chroot()), and the uid/gid with which the new process runs. All information required to start the new process is specified in a PROCESS_DATA structure. Where elements are not specified, they remain the same as the current process. The following elements can be specified in the PROCESS_DATA structure:
filename File to execute, can include arguments if argv is NULL.
argv [] List of arguments; argv [0] is filename; ends in a NULL.
path Search path (environments PATH is used if NULL).
shell Shell to use if useshell is TRUE (default is OS specific)
searchext Array of extensions to search when looking for filename
searchpath Flag: TRUE indicates path should be searched for filename
useshell Flag: TRUE indicates program should be started via a shell
createdaemon Flag: TRUE indicates a (separate) daemon should be started
wait Flag: TRUE indicates wait for process to finish
delay Amount of time to wait around for errors to happen (unix)
rootdir Root directory for new process (chroot()) if not NULL
workdir Working directory; if NULL, remains in current directory.
in File handle to use for standard input; -2 = no redirection.
out File handle to use for standard output; -2 = no redirection.
err File handle to use for standard error; -2 = no redirection.
no handles Number of file handles to pass to child process (default: 3)
envv [] Whole environment for new process; if NULL current env used
envadd Strings to add into current environment (if envv NULL).
envrm Keys to remove from current environment (if envv NULL).
username user name under which to run process
groupname groupname associated with user name
password required if calling process is not privileged
If argv is NULL, parses the filename argument into words delimited by whitespace and builds the necessary argv table automatically. Use this feature to execute a command with arguments, specified as one string. To search for the program in the path set searchpath to TRUE, and optionally supply a path to search. To run shell builtins set useshell to TRUE. The envv list consists of strings in the form "name=value", ending in a NULL pointer. If the envv argument is null, the environment of the current process is passed, with additions from envadd (if not NULL), and the keys listed in envrm removed (if not NULL). If envv is not null then the envv environment is used as is. The child process may optionally start in a new root directory and with a different user/group (if supported by the operating system). If rootdir, workdir, user, and group are all non null, then they are processed in the order: rootdir, workdir, group, user, to ensure all changes take place. Note that in this instance workdir is relative to the new root directory. Under DOS, Windows, and OS/2, the rootdir may be used to specify a change to a new drive letter (processed by _chdir() or _chdir2()). If the child command detects an error at startup, it may exit with an error status. The sleep allows this error to be collected by calling process status() after this call. Returns child process id, or 0 if there was an error. The PROCESS_DATA structure contains the following fields used for output:
pid Process identifier (as returned by function)
returncode Return code from sub process (only set if wait is TRUE)
error Code indicating error that occured (like libc errno)
Under VMS, the filename must have been defined as a command before the calling process was started; the path is disregarded. Under Windows and OS/2 processing of the #! line is emulated, and the interpreter mentioned in the #! line will be invoked on the script. Under OS/2 the filename can be the name of a CMD script, and this will be run with the interpreter specified in the first line (EXTPROC line, or "'/'*!" line; or failing that with the default command interpreter.

Source Code - (sflproc.c)

{
    /*  Implementation note: due to the size of this function, and the       */
    /*  sizeable differences between operating systems supported, the        */
    /*  implementation of this function for each operating system is in      */
    /*  a different file, and the appropriate one is included here.          */

    /*  WARNING: do not put any code here, otherwise it will prevent the     */
    /*  implementations from declaring variables.                            */

#if   (defined (__UNIX__))
#   include "sflprocu.imp"              /*  Unix implementation              */
#elif (defined (__OS2__))
#   include "sflproco.imp"              /*  OS/2 implementation              */
#elif (defined (WIN32))
#   include "sflprocw.imp"              /*  Windows (32-bit) implementation  */
#elif (defined (__VMS__))
#   include "sflprocv.imp"              /*  VMS implementation               */
#else
    return ((PROCESS) 0);               /*  Not supported on this system     */
#endif
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation