7 #include "mono/utils/mono-lazy-init.h"
8 #include "mono/metadata/w32handle.h"
10 gboolean _wapi_has_shut_down = FALSE;
21 g_assert (_wapi_has_shut_down == FALSE);
22 _wapi_has_shut_down = TRUE;
24 _wapi_error_cleanup ();
28 /* Use this instead of getpid(), to cope with linuxthreads. It's a
29 * function rather than a variable lookup because we need to get at
30 * this before share_init() might have been called. */
31 static mono_lazy_init_t _wapi_pid_init_lazy = MONO_LAZY_INIT_STATUS_NOT_INITIALIZED;
32 static pid_t _wapi_pid;
37 _wapi_pid = getpid ();
43 mono_lazy_initialize (&_wapi_pid_init_lazy, _wapi_pid_init);
49 * @handle: The handle to release
51 * Closes and invalidates @handle, releasing any resources it
52 * consumes. When the last handle to a temporary or non-persistent
53 * object is closed, that object can be deleted. Closing the same
54 * handle twice is an error.
56 * Return value: %TRUE on success, %FALSE otherwise.
58 gboolean CloseHandle(gpointer handle)
60 if (handle == INVALID_HANDLE_VALUE){
61 SetLastError (ERROR_INVALID_PARAMETER);
64 if (handle == (gpointer)0 && mono_w32handle_get_type (handle) != MONO_W32HANDLE_CONSOLE) {
65 /* Problem: because we map file descriptors to the
66 * same-numbered handle we can't tell the difference
67 * between a bogus handle and the handle to stdin.
68 * Assume that it's the console handle if that handle
71 SetLastError (ERROR_INVALID_PARAMETER);
75 mono_w32handle_unref (handle);