2 * process-private.h: Private definitions for process handles
5 * Dick Porter (dick@ximian.com)
7 * (C) 2002-2006 Novell, Inc.
10 #ifndef _WAPI_PROCESS_PRIVATE_H_
11 #define _WAPI_PROCESS_PRIVATE_H_
16 #include <mono/utils/mono-os-semaphore.h>
18 /* There doesn't seem to be a defined symbol for this */
19 #define _WAPI_PROCESS_CURRENT (gpointer)0xFFFFFFFF
22 * Handles > _WAPI_PROCESS_UNHANDLED are pseudo handles which represent processes
23 * not started by the runtime.
25 /* This marks a system process that we don't have a handle on */
26 /* FIXME: Cope with PIDs > sizeof guint */
27 #define _WAPI_PROCESS_UNHANDLED (1 << (8*sizeof(pid_t)-1))
28 #define _WAPI_PROCESS_UNHANDLED_PID_MASK (-1 & ~_WAPI_PROCESS_UNHANDLED)
29 #define WAPI_IS_PSEUDO_PROCESS_HANDLE(handle) ((GPOINTER_TO_UINT(handle) & _WAPI_PROCESS_UNHANDLED) == _WAPI_PROCESS_UNHANDLED)
30 #define WAPI_PID_TO_HANDLE(pid) GINT_TO_POINTER (_WAPI_PROCESS_UNHANDLED + (pid))
31 #define WAPI_HANDLE_TO_PID(handle) (GPOINTER_TO_UINT ((handle)) - _WAPI_PROCESS_UNHANDLED)
33 void wapi_processes_init (void);
34 extern gpointer _wapi_process_duplicate (void);
35 extern void wapi_processes_cleanup (void);
37 extern struct _WapiHandleOps _wapi_process_ops;
40 * MonoProcess describes processes we create.
41 * It contains a semaphore that can be waited on in order to wait
42 * for process termination. It's accessed in our SIGCHLD handler,
43 * when status is updated (and pid cleared, to not clash with
44 * subsequent processes that may get executed).
47 pid_t pid; /* the pid of the process. This value is only valid until the process has exited. */
48 MonoSemType exit_sem; /* this semaphore will be released when the process exits */
49 int status; /* the exit status */
50 gint32 handle_count; /* the number of handles to this mono_process instance */
51 /* we keep a ref to the creating _WapiHandle_process handle until
52 * the process has exited, so that the information there isn't lost.
56 struct MonoProcess *next;
59 typedef struct MonoProcess MonoProcess;
62 * _WapiHandle_process is a structure containing all the required information
63 * for process handling.
65 struct _WapiHandle_process
70 WapiFileTime create_time;
71 WapiFileTime exit_time;
73 size_t min_working_set;
74 size_t max_working_set;
76 struct MonoProcess *mono_process;
79 typedef struct _WapiHandle_process WapiHandle_process;
81 #endif /* _WAPI_PROCESS_PRIVATE_H_ */