1 PCREATE(3PROC) Process Control Library Functions PCREATE(3PROC) 2 3 NAME 4 Pcreate, Pxcreate, Pcreate_callback - create and control a process 5 6 LIBRARY 7 Process Control Library (libproc, -lproc) 8 9 SYNOPSIS 10 #include <libproc.h> 11 12 struct ps_prochandle * 13 Pcreate(const char *file, char *const *argv, int *perr, char *path, 14 size_t len); 15 16 struct ps_prochandle * 17 Pxcreate(const char *file, char *const *argv, char *const *envp, 18 int *perr, char *path, size_t len); 19 20 void 21 Pcreate_callback(struct ps_prochandle *P); 22 23 DESCRIPTION 24 The Pcreate() function creates a process controlled by the libproc 25 library. The Pxcreate() function does the same while also allowing the 26 replacement of the environment via envp. 27 28 Both functions cause the caller to fork(2). Followed by the child 29 calling exec(2) to load the new process image specified by file. The 30 PATH is searched for file if it is not an absolute path, similar to 31 execvp(2). 32 33 The process image will be invoked with the arguments specified by argv, 34 which should be a NULL-terminated array of character strings. Each entry 35 in the array is an individual argument. The environment of the process 36 image will be inherited from the running process if the Pcreate() 37 function is called or if the Pxcreate() function is called and the value 38 of envp is NULL. Otherwise, envp should be a NULL-terminated array of 39 character strings whose entries are in the form of key=value. For more 40 on the process environment, see environ(5). 41 42 The Pcreate_callback() function allows a way for callers to inject a 43 callback into the child process before the call to exec(2). The symbol 44 Pcreate_callback is a symbol that may be interposed on by consumers. It 45 allows the chance for the modification of signal dispositions or any 46 other changes that a caller may wish to make. 47 48 If the caller's real user or group ID is not their effective user or 49 group ID, then the child process's user and group IDs will all be reset 50 to the real user and group id. 51 52 The perr argument must be a non-NULL pointer. If the Pcreate() or 53 Pxcreate() functions fail, the value pointed to will be filled in with a 54 more detailed error code listed in ERRORS. A human-readable error 55 message is obtained with Pcreate_error(3PROC). 56 57 Multiple executables named file may exist on the PATH. To determine the 58 full path of the executable pass a non-NULL path pointer. Upon 59 successful completion of Pcreate() or Pxcreate() the path pointer will 60 contain the full path up to len bytes, including the NUL character. 61 62 Upon successful completion of the Pcreate() or Pxcreate() function, a 63 handle to the process is returned. This handle is usable with other 64 libproc routines and will persist until either Pfree(3PROC) or 65 Prelease(3PROC) is called on the resulting handle. The process created 66 is stopped just after return from the exec(2) family of system calls. 67 The process will not run, unless the caller sets it running or releases 68 its handle to the process. 69 70 A 32-bit process cannot use this interface to launch or control a 64-bit 71 process. However, a 64-bit process can create and control both 32-bit 72 and 64-bit processes. 73 74 RETURN VALUES 75 Upon successful completion, both the Pcreate() and Pxcreate() functions 76 create a new process and return a libproc handle to it. Otherwise, NULL 77 is returned and perr is filled in with the corresponding error. 78 79 ERRORS 80 The Pcreate() and Pxcreate() functions will fail if: 81 82 C_FORK The call to fork(2) failed. 83 84 C_INTR The operation was interrupted by a signal. 85 86 C_LP64 The calling process is 32-bit, but it attempted to 87 control a 64-bit process. 88 89 C_NOEXEC The specified file or the one found by searching PATH 90 cannot be executed. 91 92 C_NOENT The specified file does not exist or it could not be 93 found by searching PATH. 94 95 C_PERM The specified file or the one found by searching PATH 96 is set-id or unreadable. 97 98 C_STRANGE An unanticipated system error occurred while trying to 99 create the process and its handle. When this occurs, 100 then the value of errno is meaningful. See errno(3C) 101 for more information and Intro(2) for the list of 102 possible errors. 103 104 INTERFACE STABILITY 105 Uncommitted 106 107 MT-LEVEL 108 MT-Safe 109 110 SEE ALSO 111 exec(2), execvp(2), fork(2), Intro(2), errno(3C), libproc(3LIB), 112 Pcreate_error(3PROC), Pfree(3PROC), Prelease(3PROC) 113 114 illumos May 11, 2016 illumos