VirtualBox

source: vbox/trunk/include/iprt/process.h@ 6356

Last change on this file since 6356 was 5999, checked in by vboxsync, 17 years ago

The Giant CDDL Dual-License Header Change.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 KB
Line 
1/** @file
2 * innotek Portable Runtime - Process Management.
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___iprt_process_h
27#define ___iprt_process_h
28
29#include <iprt/cdefs.h>
30#include <iprt/types.h>
31
32__BEGIN_DECLS
33
34/** @defgroup grp_rt_process RTProc - Process Management
35 * @ingroup grp_rt
36 * @{
37 */
38
39
40/**
41 * Process priority.
42 *
43 * The process priority is used to select how scheduling properties
44 * are assigned to the different thread types (see THREADTYPE).
45 *
46 * In addition to using the policy assigned to the process at startup (DEFAULT)
47 * it is possible to change the process priority at runtime. This allows for
48 * a GUI, resource manager or admin to adjust the general priorty of a task
49 * without upsetting the fine-tuned priority of the threads within.
50 */
51typedef enum RTPROCPRIORITY
52{
53 /** Invalid priority. */
54 RTPROCPRIORITY_INVALID = 0,
55 /** Default priority.
56 * Derive the schedulding policy from the priority of the RTR3Init()
57 * and RTProcSetPriority() callers and the rights the process have
58 * to alter its own priority.
59 */
60 RTPROCPRIORITY_DEFAULT,
61 /** Flat priority.
62 * Assumes a scheduling policy which puts the process at the default priority
63 * and with all thread at the same priority.
64 */
65 RTPROCPRIORITY_FLAT,
66 /** Low priority.
67 * Assumes a scheduling policy which puts the process mostly below the
68 * default priority of the host OS.
69 */
70 RTPROCPRIORITY_LOW,
71 /** Normal priority.
72 * Assume a scheduling policy which shares the cpu resources fairly with
73 * other processes running with the default priority of the host OS.
74 */
75 RTPROCPRIORITY_NORMAL,
76 /** High priority.
77 * Assumes a scheduling policy which puts the task above the default
78 * priority of the host OS. This policy might easily cause other tasks
79 * in the system to starve.
80 */
81 RTPROCPRIORITY_HIGH,
82 /** Last priority, used for validation. */
83 RTPROCPRIORITY_LAST
84} RTPROCPRIORITY;
85
86
87/**
88 * Get the current process identifier.
89 *
90 * @returns Process identifier.
91 */
92RTDECL(RTPROCESS) RTProcSelf(void);
93
94
95#ifdef IN_RING0
96/**
97 * Get the current process handle.
98 *
99 * @returns Ring-0 process handle.
100 */
101RTR0DECL(RTR0PROCESS) RTR0ProcHandleSelf(void);
102#endif
103
104
105#ifdef IN_RING3
106
107/**
108 * Attempts to alter the priority of the current process.
109 *
110 * @returns iprt status code.
111 * @param enmPriority The new priority.
112 */
113RTR3DECL(int) RTProcSetPriority(RTPROCPRIORITY enmPriority);
114
115/**
116 * Gets the current priority of this process.
117 *
118 * @returns The priority (see RTPROCPRIORITY).
119 */
120RTR3DECL(RTPROCPRIORITY) RTProcGetPriority(void);
121
122/**
123 * Create a child process.
124 *
125 * @returns iprt status code.
126 * @param pszExec Executable image to use to create the child process.
127 * @param papszArgs Pointer to an array of arguments to the child. The array terminated by an entry containing NULL.
128 * @param Env Handle to the environment block for the child.
129 * @param fFlags Flags. This is currently reserved and must be 0.
130 * @param pProcess Where to store the process identifier on successful return.
131 * The content is not changed on failure. NULL is allowed.
132 */
133RTR3DECL(int) RTProcCreate(const char *pszExec, const char * const *papszArgs, RTENV Env, unsigned fFlags, PRTPROCESS pProcess);
134
135/**
136 * Process exit reason.
137 */
138typedef enum RTPROCEXITREASON
139{
140 /** Normal exit. iStatus contains the exit code. */
141 RTPROCEXITREASON_NORMAL = 1,
142 /** Any abnormal exit. iStatus is undefined. */
143 RTPROCEXITREASON_ABEND,
144 /** Killed by a signal. The iStatus field contains the signal number. */
145 RTPROCEXITREASON_SIGNAL
146} RTPROCEXITREASON;
147
148/**
149 * Process exit status.
150 */
151typedef struct RTPROCSTATUS
152{
153 /** The process exit status if the exit was a normal one. */
154 int iStatus;
155 /** The reason the process terminated. */
156 RTPROCEXITREASON enmReason;
157} RTPROCSTATUS;
158/** Pointer to a process exit status structure. */
159typedef RTPROCSTATUS *PRTPROCSTATUS;
160/** Pointer to a const process exit status structure. */
161typedef const RTPROCSTATUS *PCRTPROCSTATUS;
162
163
164/** Flags for RTProcWait().
165 * @{ */
166/** Block indefinitly waiting for the process to exit. */
167#define RTPROCWAIT_FLAGS_BLOCK 0
168/** Don't block, just check if the process have exitted. */
169#define RTPROCWAIT_FLAGS_NOBLOCK 1
170/** @} */
171
172/**
173 * Waits for a process, resumes on interruption.
174 *
175 * @returns VINF_SUCCESS when the status code for the process was collected and put in *pProcStatus.
176 * @returns VERR_PROCESS_NOT_FOUND if the specified process wasn't found.
177 * @returns VERR_PROCESS_RUNNING when the RTPROCWAIT_FLAG_NOBLOCK and the process haven't exitted yet.
178 *
179 * @param Process The process to wait for.
180 * @param fFlags The wait flags, any of the RTPROCWAIT_FLAGS_ \#defines.
181 * @param pProcStatus Where to store the exit status on success.
182 */
183RTR3DECL(int) RTProcWait(RTPROCESS Process, unsigned fFlags, PRTPROCSTATUS pProcStatus);
184
185/**
186 * Waits for a process, returns on interruption.
187 *
188 * @returns VINF_SUCCESS when the status code for the process was collected and put in *pProcStatus.
189 * @returns VERR_PROCESS_NOT_FOUND if the specified process wasn't found.
190 * @returns VERR_PROCESS_RUNNING when the RTPROCWAIT_FLAG_NOBLOCK and the process haven't exitted yet.
191 * @returns VERR_INTERRUPTED when the wait was interrupted by the arrival of a signal or other async event.
192 *
193 * @param Process The process to wait for.
194 * @param fFlags The wait flags, any of the RTPROCWAIT_FLAGS_ \#defines.
195 * @param pProcStatus Where to store the exit status on success.
196 */
197RTR3DECL(int) RTProcWaitNoResume(RTPROCESS Process, unsigned fFlags, PRTPROCSTATUS pProcStatus);
198
199/**
200 * Terminates (kills) a running process.
201 *
202 * @returns IPRT status code.
203 * @param Process The process to terminate.
204 */
205RTR3DECL(int) RTProcTerminate(RTPROCESS Process);
206
207/**
208 * Gets the processor affinity mask of the current process.
209 *
210 * @returns The affinity mask.
211 */
212RTR3DECL(uint64_t) RTProcGetAffinityMask(void);
213
214/**
215 * Gets the executable image name of the current process.
216 *
217 *
218 * @returns pszExecName on success. NULL on buffer overflow or other errors.
219 *
220 * @param pszExecName Where to store the name.
221 * @param cchExecName The size of the buffer.
222 */
223RTR3DECL(char *) RTProcGetExecutableName(char *pszExecName, size_t cchExecName);
224
225#endif /* IN_RING3 */
226
227/** @} */
228
229__END_DECLS
230
231#endif
232
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette