[runtime] Updates comments.
[mono.git] / mono / io-layer / process-private.h
1 /*
2  * process-private.h: Private definitions for process handles
3  *
4  * Author:
5  *      Dick Porter (dick@ximian.com)
6  *
7  * (C) 2002-2006 Novell, Inc.
8  */
9
10 #ifndef _WAPI_PROCESS_PRIVATE_H_
11 #define _WAPI_PROCESS_PRIVATE_H_
12
13 #include <config.h>
14 #include <glib.h>
15
16 /* There doesn't seem to be a defined symbol for this */
17 #define _WAPI_PROCESS_CURRENT (gpointer)0xFFFFFFFF
18
19 /*
20  * Handles > _WAPI_PROCESS_UNHANDLED are pseudo handles which represent processes
21  * not started by the runtime.
22  */
23 /* This marks a system process that we don't have a handle on */
24 /* FIXME: Cope with PIDs > sizeof guint */
25 #define _WAPI_PROCESS_UNHANDLED (1 << (8*sizeof(pid_t)-1))
26 #define _WAPI_PROCESS_UNHANDLED_PID_MASK (-1 & ~_WAPI_PROCESS_UNHANDLED)
27 #define WAPI_IS_PSEUDO_PROCESS_HANDLE(handle) ((GPOINTER_TO_UINT(handle) & _WAPI_PROCESS_UNHANDLED) == _WAPI_PROCESS_UNHANDLED)
28 #define WAPI_PID_TO_HANDLE(pid) GINT_TO_POINTER (_WAPI_PROCESS_UNHANDLED + (pid))
29 #define WAPI_HANDLE_TO_PID(handle) (GPOINTER_TO_UINT ((handle)) - _WAPI_PROCESS_UNHANDLED)
30
31 void wapi_processes_init (void);
32 extern gpointer _wapi_process_duplicate (void);
33 extern void wapi_processes_cleanup (void);
34
35 extern struct _WapiHandleOps _wapi_process_ops;
36
37 /*
38  * MonoProcess describes processes we create.
39  * It contains a semaphore that can be waited on in order to wait
40  * for process termination. It's accessed in our SIGCHLD handler,
41  * when status is updated (and pid cleared, to not clash with 
42  * subsequent processes that may get executed).
43  */
44 struct MonoProcess {
45         pid_t pid; /* the pid of the process. This value is only valid until the process has exited. */
46         MonoSemType exit_sem; /* this semaphore will be released when the process exits */
47         int status; /* the exit status */
48         gint32 handle_count; /* the number of handles to this mono_process instance */
49         /* we keep a ref to the creating _WapiHandle_process handle until
50          * the process has exited, so that the information there isn't lost.
51          */
52         gpointer handle;
53         struct MonoProcess *next;
54 };
55
56
57 /*
58  * _WapiHandle_process is a structure containing all the required information
59  * for process handling.
60  */
61 struct _WapiHandle_process
62 {
63         pid_t id;
64         guint32 exitstatus;
65         gpointer main_thread;
66         WapiFileTime create_time;
67         WapiFileTime exit_time;
68         char *proc_name;
69         size_t min_working_set;
70         size_t max_working_set;
71         gboolean exited;
72         struct MonoProcess *mono_process;
73 };
74
75 typedef struct _WapiHandle_process WapiHandle_process;
76
77 #endif /* _WAPI_PROCESS_PRIVATE_H_ */