Changeset 936 in vbox for trunk/include/iprt
- Timestamp:
- Feb 15, 2007 8:58:51 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 18671
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/env.h
r880 r936 1 1 /** @file 2 * InnoTek Portable Runtime - Process Management.2 * InnoTek Portable Runtime - Process Environment Strings. 3 3 */ 4 4 … … 19 19 */ 20 20 21 #ifndef __iprt_ process_h__22 #define __iprt_ process_h__21 #ifndef __iprt_env_h__ 22 #define __iprt_env_h__ 23 23 24 24 #include <iprt/cdefs.h> … … 27 27 __BEGIN_DECLS 28 28 29 /** @defgroup grp_rt_ process RTProc - Process Management29 /** @defgroup grp_rt_env RTProc - Process Environment Strings 30 30 * @ingroup grp_rt 31 31 * @{ 32 32 */ 33 33 34 35 /**36 * Process priority.37 *38 * The process priority is used to select how scheduling properties39 * are assigned to the different thread types (see THREADTYPE).40 *41 * In addition to using the policy assigned to the process at startup (DEFAULT)42 * it is possible to change the process priority at runtime. This allows for43 * a GUI, resource manager or admin to adjust the general priorty of a task44 * without upsetting the fine-tuned priority of the threads within.45 */46 typedef enum RTPROCPRIORITY47 {48 /** Invalid priority. */49 RTPROCPRIORITY_INVALID = 0,50 /** Default priority.51 * Derive the schedulding policy from the priority of the RTR3Init()52 * and RTProcSetPriority() callers and the rights the process have53 * to alter its own priority.54 */55 RTPROCPRIORITY_DEFAULT,56 /** Flat priority.57 * Assumes a scheduling policy which puts the process at the default priority58 * and with all thread at the same priority.59 */60 RTPROCPRIORITY_FLAT,61 /** Low priority.62 * Assumes a scheduling policy which puts the process mostly below the63 * default priority of the host OS.64 */65 RTPROCPRIORITY_LOW,66 /** Normal priority.67 * Assume a scheduling policy which shares the cpu resources fairly with68 * other processes running with the default priority of the host OS.69 */70 RTPROCPRIORITY_NORMAL,71 /** High priority.72 * Assumes a scheduling policy which puts the task above the default73 * priority of the host OS. This policy might easily cause other tasks74 * in the system to starve.75 */76 RTPROCPRIORITY_HIGH,77 /** Last priority, used for validation. */78 RTPROCPRIORITY_LAST79 } RTPROCPRIORITY;80 81 82 /**83 * Get the current process identifier.84 *85 * @returns Process identifier.86 */87 RTDECL(RTPROCESS) RTProcSelf(void);88 89 90 #ifdef IN_RING091 /**92 * Get the current process handle.93 *94 * @returns Ring-0 process handle.95 */96 RTR0DECL(RTR0PROCESS) RTR0ProcHandleSelf(void);97 #endif98 99 100 34 #ifdef IN_RING3 101 35 102 36 /** 103 * Attempts to alter the priority of the current process. 104 * 105 * @returns iprt status code. 106 * @param enmPriority The new priority. 37 * Gets an environment variable (getenv). 38 * 39 * The caller is responsible for ensuring that nobody changes the environment 40 * while it's using the returned string pointer! 41 * 42 * @returns Pointer to read only string on success, NULL if the variable wasn't found. 43 * 44 * @param pszVar The environment variable name. 107 45 */ 108 RT R3DECL(int) RTProcSetPriority(RTPROCPRIORITY enmPriority);46 RTDECL(const char *) RTEnvGet(const char *pszVar); 109 47 110 48 /** 111 * Gets the current priority of this process. 112 * 113 * @returns The priority (see RTPROCPRIORITY). 49 * Puts an variable=value string into the environment (putenv). 50 * 51 * @returns IPRT status code. Typical error is VERR_NO_MEMORY. 52 * 53 * @param pszVarEqualValue The variable '=' value string. If the value and '=' is 54 * omitted, the variable is removed from the environment. 114 55 */ 115 RT R3DECL(RTPROCPRIORITY) RTProcGetPriority(void);56 RTDECL(int) RTEnvPut(const char *pszVarEqualValue); 116 57 117 /** 118 * Create a child process. 119 * 120 * @returns iprt status code. 121 * @param pszExec Executable image to use to create the child process. 122 * @param papszArgs Pointer to an array of arguments to the child. The array terminated by an entry containing NULL. 123 * @param papszEnv Pointer to array of environment variables for the child process. An NULL entry 124 * terminates the array. The variables are on the form '\<var\>=\<value\>'. 125 * If NULL the environment of the process will be used. 126 * @param fFlags Flags. This is currently reserved and must be 0. 127 * @param pProcess Where to store the process identifier on successful return. 128 * The content is not changed on failure. NULL is allowed. 129 */ 130 RTR3DECL(int) RTProcCreate(const char *pszExec, const char * const *papszArgs, const char * const *papszEnv, unsigned fFlags, PRTPROCESS pProcess); 131 132 /** 133 * Process exit reason. 134 */ 135 typedef enum RTPROCEXITREASON 136 { 137 /** Normal exit. iStatus contains the exit code. */ 138 RTPROCEXITREASON_NORMAL = 1, 139 /** Any abnormal exit. iStatus is undefined. */ 140 RTPROCEXITREASON_ABEND, 141 /** Killed by a signal. The iStatus field contains the signal number. */ 142 RTPROCEXITREASON_SIGNAL 143 } RTPROCEXITREASON; 144 145 /** 146 * Process exit status. 147 */ 148 typedef struct RTPROCSTATUS 149 { 150 /** The process exit status if the exit was a normal one. */ 151 int iStatus; 152 /** The reason the process terminated. */ 153 RTPROCEXITREASON enmReason; 154 } RTPROCSTATUS; 155 /** Pointer to a process exit status structure. */ 156 typedef RTPROCSTATUS *PRTPROCSTATUS; 157 /** Pointer to a const process exit status structure. */ 158 typedef const RTPROCSTATUS *PCRTPROCSTATUS; 159 160 161 /** Flags for RTProcWait(). 162 * @{ */ 163 /** Block indefinitly waiting for the process to exit. */ 164 #define RTPROCWAIT_FLAGS_BLOCK 0 165 /** Don't block, just check if the process have exitted. */ 166 #define RTPROCWAIT_FLAGS_NOBLOCK 1 167 /** @} */ 168 169 /** 170 * Waits for a process, resumes on interruption. 171 * 172 * @returns VINF_SUCCESS when the status code for the process was collected and put in *pProcStatus. 173 * @returns VERR_PROCESS_NOT_FOUND if the specified process wasn't found. 174 * @returns VERR_PROCESS_RUNNING when the RTPROCWAIT_FLAG_NOBLOCK and the process haven't exitted yet. 175 * 176 * @param Process The process to wait for. 177 * @param fFlags The wait flags, any of the RTPROCWAIT_FLAGS_ \#defines. 178 * @param pProcStatus Where to store the exit status on success. 179 */ 180 RTR3DECL(int) RTProcWait(RTPROCESS Process, unsigned fFlags, PRTPROCSTATUS pProcStatus); 181 182 /** 183 * Waits for a process, returns on interruption. 184 * 185 * @returns VINF_SUCCESS when the status code for the process was collected and put in *pProcStatus. 186 * @returns VERR_PROCESS_NOT_FOUND if the specified process wasn't found. 187 * @returns VERR_PROCESS_RUNNING when the RTPROCWAIT_FLAG_NOBLOCK and the process haven't exitted yet. 188 * @returns VERR_INTERRUPTED when the wait was interrupted by the arrival of a signal or other async event. 189 * 190 * @param Process The process to wait for. 191 * @param fFlags The wait flags, any of the RTPROCWAIT_FLAGS_ \#defines. 192 * @param pProcStatus Where to store the exit status on success. 193 */ 194 RTR3DECL(int) RTProcWaitNoResume(RTPROCESS Process, unsigned fFlags, PRTPROCSTATUS pProcStatus); 195 196 /** 197 * Terminates (kills) a running process. 198 * 199 * @returns IPRT status code. 200 * @param Process The process to terminate. 201 */ 202 RTR3DECL(int) RTProcTerminate(RTPROCESS Process); 203 204 /** 205 * Gets the processor affinity mask of the current process. 206 * 207 * @returns The affinity mask. 208 */ 209 RTR3DECL(uint64_t) RTProcGetAffinityMask(void); 210 211 /** 212 * Gets the executable image name of the current process. 213 * 214 * 215 * @returns pszExecName on success. NULL on buffer overflow or other errors. 216 * 217 * @param pszExecName Where to store the name. 218 * @param cchExecName The size of the buffer. 219 */ 220 RTR3DECL(char *) RTProcGetExecutableName(char *pszExecName, size_t cchExecName); 58 /** @todo Add the missing environment APIs: safe, printf like, and various modifications. */ 221 59 222 60 #endif /* IN_RING3 */
Note:
See TracChangeset
for help on using the changeset viewer.