char *file,*arg1,*arg2,...,*argn,**arglist;
int runc (func,file,arg0,arg1,arg2,...,argn,0);
int runcv (func,file,arglist);
int runcp (func,file,arg0,arg1,arg2,...,argn,0);
int runcvp (func,file,arglist);
char *file,*arg1,*arg2,...,*argn,**arglist;
int (*func)();
Run and runv return -1 if vfork(2) or exec(2)failorthechildwasterminated by a signal; the exit code of the process otherwise.
Runp and runvp are identical to run and runv, but perform path searching for the process by using execlp and execvp. These routines use the PATH environment parameter as a list of directory names separated by colons; the executable file is sought in each directory until it is found or all directories have been searched. If the file is not found, -1 is returned.
The proper way to execute system programs is via runp or runvp for most purposes; for example, if you want to move file "a" to "b", the best way to do this via system programs is this:
Note that no directory name is needed along with the name of the file (e.g. /bin/mv is not necessary), and that the program name should be both file and arg0. This call is similar to:
system ("mv a b");but is much faster to execute.
Runc, runcp, runcv, and runcvp function analagously to their similarly named counterparts described above. However, they also invoke the specified function func in the context of the child process in order to first perform any application specific initialization that may be needed before attempting to execute the program. If func is null, these routines are identical to their simpler counterparts.
The use of setgid and setuid means that, if the parent process gained privileges through the use of special file mode bits (see chmod(2)), the child process will not inherit these privileges. This makes run "safe" for system programs which require special privileges, and usually has no effect on user programs.