PROC(3)
π PROC(3) β Library Functions Manual π
Okay bestie, this is the PROC(3) page from the Library Functions Manual, and itβs giving portable process-control realness. π«Ά
β¨ NAME β¨
proc β process control routines
π οΈ SYNOPSIS π οΈ
#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);
π DESCRIPTION π
These routines are your 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). No cap. β¨
πΈ procopen πΈ
procopen runs 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 PATH environment variable from the calling environment. If command is 0 then the current shell is used (see pathshell(3)). If envv is not 0 then it is a 0 terminated 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 0 then it is a 0 terminaled vector of operations to perform. In the following, context is a combination of PROC_FD_CHILD and PROC_FD_PARENT for the child and parent process context respectively. Valid operations are:
PROC_FD_CLOSE(fd,context)β the file descriptorfdis closed incontext.PROC_FD_DUP(from,to,context)β the file descriptorfromisdup(2)'d into the file descriptortoincontext.PROC_SIG_DFL(sig)β the signal handler forsigis set toSIG_DFLin the child context.PROC_SIG_IGN(sig)β the signal handler forsigis set toSIG_IGNin the child context.PROC_SYS_PGRP(pgid)β the child process group is set topgid.pgidmay have the following values:<0β the child process becomes a session leader.0β the child process is in the parent process group.1β the child process becomes a process group leader.>1β the child process joins the process grouppgid.
PROC_SYS_UMASK(mask)β the child process group file creation mask is set tomask.
flags is the inclusive-or of the following:
PROC_ARGMODβargv[-1]andargv[0]may be modified. This is an optimization that avoids an environment vectorrealloc(3)whencommandis a shell script.PROC_BACKGROUNDβ standard shell & setup is done for the child process.PROC_CLEANUPβ parent process redirection file descriptors are closed on error.PROC_DAEMONβ standard daemon setup is done for the child process.PROC_ENVCLEARβ the child environment is cleared beforeenvvis added.PROC_GIDβ the child effective group id is set to the real group id.PROC_IGNOREβ parent pipe errors are ignored.PROC_OVERLAYβ the current process is overlayed bycommandif possible (i.e., thefork(2)call is omitted).PROC_PARANOIDβ paranoid:commandis searched using the default standardPATH; the child environment variablePATHis set to the default standard; thePROC_GIDandPROC_UIDmodes are set; only/bin/shis used to executecommandif it is a shell script.PROC_PRIVELEGEDβ if the effective user id is0then the child real user id is set to0and the child real group id is set to the effective group id.PROC_READβproc.rfdis connected tocommand's standard output.PROC_SESSIONβ the child process becomes a session group leader. (Equivalent to theopventryPROC_SYS_PGRP(-1).)PROC_UIDβ the child effective user id is set to the real user id.PROC_WRITEβproc.wfdis connected to commandβs standard input.
π¦ The returned struct π¦
The return value is a pointer to a structure with the following members:
pid_t pidβ the child process id.pid_t pgrpβ the child process group.int rfdβ a read file descriptor connected tocommand's standard output.int wfdβ a write file descriptor connected tocommand's standard input.
If an error occurs then 0 is returned.
π procclose π
procclose waits for the process proc to complete and then closes the command stream proc. The command exit status is returned. -1 is returned if the child portion of procopen failed.
π§ procfree π§
procfree frees the process stream without waiting for command to complete. Presumably some other mechanism will be used to wait for proc.pid.
π procrun π
procrun combines procopen and procclose with the flags PROC_GID|PROC_UID and returns the command exit status.
π SEE ALSO π
popen(3)sfpopen(3)spawnveg(3)system(3)
π thatβs the whole page, bestie β the footer just repeats PROC(3), with no extra source/version or date tea to spill, so consider this your cute sign-off. πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: ksh-devel 93vu-bp160.1.33 Β· CPL-1.0
- opensuse-leap 16.0: ksh-devel 93vu-bp160.1.33 Β· CPL-1.0
- opensuse-leap 16.0: ksh-devel 93vu-bp160.1.33 Β· CPL-1.0
- opensuse-leap 16.0: ksh-devel 93vu-bp160.1.33 Β· CPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms