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