Merge pull request #656 from LogosBible/collection_lock
[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 /* This marks a system process that we don't have a handle on */
20 /* FIXME: Cope with PIDs > sizeof guint */
21 #define _WAPI_PROCESS_UNHANDLED (1 << (8*sizeof(pid_t)-1))
22 #define _WAPI_PROCESS_UNHANDLED_PID_MASK (-1 & ~_WAPI_PROCESS_UNHANDLED)
23
24 extern gpointer _wapi_process_duplicate (void);
25 extern void wapi_processes_cleanup (void);
26
27 extern struct _WapiHandleOps _wapi_process_ops;
28
29 #define _WAPI_PROC_NAME_MAX_LEN _POSIX_PATH_MAX
30
31 /*
32  * MonoProcess describes processes we create.
33  * It contains a semaphore that can be waited on in order to wait
34  * for process termination. It's accessed in our SIGCHLD handler,
35  * when status is updated (and pid cleared, to not clash with 
36  * subsequent processes that may get executed).
37  */
38 struct MonoProcess {
39         pid_t pid; /* the pid of the process. This value is only valid until the process has exited. */
40         MonoSemType exit_sem; /* this semaphore will be released when the process exits */
41         int status; /* the exit status */
42         gint32 handle_count; /* the number of handles to this mono_process instance */
43         /* we keep a ref to the creating _WapiHandle_process handle until
44          * the process has exited, so that the information there isn't lost.
45          * If we put the information there in this structure, it won't be
46          * available to other processes when using shared handles. */
47         gpointer handle;
48         struct MonoProcess *next;
49 };
50
51
52 /*
53  * _WapiHandle_process is a structure containing all the required information
54  * for process handling.
55  * The mono_process field is only present if this process has created
56  * the corresponding process.
57  */
58 struct _WapiHandle_process
59 {
60         pid_t id;
61         guint32 exitstatus;
62         gpointer main_thread;
63         WapiFileTime create_time;
64         WapiFileTime exit_time;
65         gchar proc_name[_WAPI_PROC_NAME_MAX_LEN];
66         size_t min_working_set;
67         size_t max_working_set;
68         gboolean exited;
69         pid_t self; /* mono_process is shared among processes, but only usable in the process that created it */
70         struct MonoProcess *mono_process;
71 };
72
73 #endif /* _WAPI_PROCESS_PRIVATE_H_ */