6 #include "process-private.h"
7 #include "socket-private.h"
9 #include "mono/utils/mono-lazy-init.h"
10 #include "mono/utils/w32handle.h"
12 gboolean _wapi_has_shut_down = FALSE;
18 _wapi_processes_init ();
25 g_assert (_wapi_has_shut_down == FALSE);
26 _wapi_has_shut_down = TRUE;
28 _wapi_error_cleanup ();
29 wapi_processes_cleanup ();
33 /* Use this instead of getpid(), to cope with linuxthreads. It's a
34 * function rather than a variable lookup because we need to get at
35 * this before share_init() might have been called. */
36 static mono_lazy_init_t _wapi_pid_init_lazy = MONO_LAZY_INIT_STATUS_NOT_INITIALIZED;
37 static pid_t _wapi_pid;
42 _wapi_pid = getpid ();
48 mono_lazy_initialize (&_wapi_pid_init_lazy, _wapi_pid_init);
52 /* Lots more to implement here, but this is all we need at the moment */
54 DuplicateHandle (gpointer srcprocess, gpointer src, gpointer targetprocess, gpointer *target,
55 guint32 access G_GNUC_UNUSED, gboolean inherit G_GNUC_UNUSED, guint32 options G_GNUC_UNUSED)
57 if (srcprocess != _WAPI_PROCESS_CURRENT || targetprocess != _WAPI_PROCESS_CURRENT) {
58 /* Duplicating other process's handles is not supported */
59 SetLastError (ERROR_INVALID_HANDLE);
63 if (src == _WAPI_PROCESS_CURRENT) {
64 *target = _wapi_process_duplicate ();
66 mono_w32handle_ref (src);
75 * @handle: The handle to release
77 * Closes and invalidates @handle, releasing any resources it
78 * consumes. When the last handle to a temporary or non-persistent
79 * object is closed, that object can be deleted. Closing the same
80 * handle twice is an error.
82 * Return value: %TRUE on success, %FALSE otherwise.
84 gboolean CloseHandle(gpointer handle)
86 if (handle == INVALID_HANDLE_VALUE){
87 SetLastError (ERROR_INVALID_PARAMETER);
90 if (handle == (gpointer)0 && mono_w32handle_get_type (handle) != MONO_W32HANDLE_CONSOLE) {
91 /* Problem: because we map file descriptors to the
92 * same-numbered handle we can't tell the difference
93 * between a bogus handle and the handle to stdin.
94 * Assume that it's the console handle if that handle
97 SetLastError (ERROR_INVALID_PARAMETER);
101 mono_w32handle_unref (handle);