Linux repositories inspector



Korn Shell development environment


proc - process control routines


#include <proc.h>

Proc_t* procopen(const char*
command, char** argv, char** envv, long* opv, long flags); int procfree(Proc_t* proc); int procclose(Proc_t* proc); int procrun(const char* command, char** argv);


These routines provide a portable interface to process creation and execution. They work on systems with fork(2) and exec(2) as well as on systems with only spawnve(2) or spanwveg(3).
procopenruns command with arguments argv, environment modifications in envv, file descriptor, signal and process group operations in opv and flags in flags.
command is searched for using the PATHenvironment variable from the calling environment. If command is 0then the current shell is used (see pathshell(3)). If envv is not 0then it is a 0terminated vector of name[=value] strings that are added to the command environment using setenviron(3). If name appears in the parent environment then its value is replaced with the new value. If =value is omitted then name is removed from the child environment. The _environment variable is set to contain the pathname for command and will appear at the top of the child environment.
If opv is not 0then it is a 0 terminaled vector of operations to perform. In the following context is a combination of PROC_FD_CHILDand PROC_FD_PARENTfor the child and parent process context respectively. Valid operations are:
The file descriptor fd is closed in context.
The file descriptor from is dup(2)’d into the file descriptor to in context.
The signal handler for sig is set to SIG_DFLin the child context.
The signal handler for sig is set to SIG_IGNin the child context.
The child process group is set to pgid. pgid may have the following values:
<0The child process becomes a session leader.
0The child process is in the parent process group.
1The child process becomes a process group leader.
>1The child process joins the process group pgid.
The child process group file creation mask is set to mask.
flags is the inclusive-or of the following:
PROC_ARGMODargv[-1] and argv[0] may be modified. This is an optimization that avoids an environment vector realloc(3) when command is a shell script.
PROC_BACKGROUNDStandard shell &setup is done for the child process.
PROC_CLEANUPParent process redirection file discriptors are closed on error.
PROC_DAEMONStandard daemon setup is done for the child process.
PROC_ENVCLEARThe child environment is cleared before envv is added.
PROC_GIDThe child effective group id is set to the real group id.
PROC_IGNOREParent pipe errors are ignored.
PROC_OVERLAYThe current process is overlayed by command if possible (i.e., the fork(2) call is omitted).
PROC_PARANOIDParanoid: command is searched using the default standard PATH the child environment variable PATHis set to the default standard; the PROC_GIDand PROC_UIDmodes are set; only /bin/shis used to execute command if it is a shell script.
PROC_PRIVELEGEDIf the effective user id is 0then the child real user id is set to 0and the child real group id is set to the effective group id.
PROC_READproc.rfd is connected to command’s standard output.
PROC_SESSIONThe child process becomes a session group leader. (Equivalent to the opv entry PROC_SYS_PGRP(-1)
PROC_UIDThe child effective user id is set to the real user id.
PROC_WRITEproc.wfd is connected to commands’s standard input.
The return value is a pointer to a structure with the following members:
pid_t pidThe child process id.
pid_t pgrpThe child process group.
int rfdA read file descriptor connected to command’s standard output.
int wfdA write file descriptor connected to command’s standard input.
If an error occurs then 0is returned.
procclosewaits for the process proc to complete and then closes the command stream proc. The command exit status is returned. -1is returned if the child portion of procopenfailed.
procfreefrees the process stream without waiting for command to complete. Presumably some other mechanism will be used to wait for
procruncombines procopenand procclosewith the flags PROC_GID|PROC_UIDand returns the command exit status.
⇧ Top