29. november 1999 - 17:18
#1
Nu kender jeg ikke NT, men hvorfor kan du ikke bruge system()?
Ellers er her nogle andre funktioner - aner ikke om du kan bruge dem...
# spawn... functions
The spawn... functions let your program run other files (child processes)
and return control to your program when those processes finish.
Prototype in process.h
Use these spawn... functions when you know how many separate arguments
you'll have:
int spawnl(int mode, char *path,
char *arg0, ..., NULL);
int spawnle(int mode, char *path,
char *arg0, ..., NULL,
char *envp[]);
int spawnlp(int mode, char *path,
char *arg0, ..., NULL);
int spawnlpe(int mode, char *path,
char *arg0, ..., NULL,
char *envp[]);
These spawn... functions are used when you don't know in advance how many
separate arguments you will have:
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[]);
The letters at the end of each spawn... function identify which variation is
used:
Ltr Variation used
ÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
p ³ search the DOS path for child
l ³ spawn passed a fixed list of args
v ³ spawn passed a variable list of args
e ³ spawn passes an envp ptr, allowing
³ you to alter the environment the
³ child will have
On a successful execution, the return value is the child process's exit
status (0 for normal termination). If the child specifically calls exit with
a nonzero argument, its exit status can be set to a nonzero value.
If the process can't be spawn...ed successfully, the spawn... functions will
return -1.
# exec... functions
The exec... functions let your program run other files (child processes).
When an exec... call succeeds, the child process overlays the parent
process. There must be sufficient memory available for loading and executing
the child process.
Prototype in process.h
Use these exec... functions when you know how many separate arguments you'll
have:
int execl(char *path, char *arg0, .., NULL);
int execle(char *path, char *arg0, .., NULL,
char **env);
int execlp(char *path, char *arg0, ..);
int execlpe(char *path, char *arg0, ..,
NULL, char **env);
These exec... functions are used when you don't know in advance how many
separate arguments you will have:
int execv(char *path, char *argv[]);
int execve(char *path, char *argv[],
char **env);
int execvp(char *path, char *argv[]);
int execvpe(char *path, char *argv[],
char **env);
The letters at the end of each exec... function identify which variation is
used:
Ltr ³ Variation used
ÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
p ³ search the DOS path for child
³
l ³ exec passed a fixed list of args
³
v ³ exec passed a variable list of args
³
e ³ exec passes an envp ptr, allowing
³ you to alter the environment the
³ child will have
If successful, the exec functions do not return. On error, the exec
functions return -1 and set errno.