From 917e4f39bb73ce590c86e2e9ef2767a25207e900 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Thu, 11 Feb 2016 17:55:24 -0500 Subject: [PATCH] [io] Release Pipe and Console shared handles Allows opening a character device or named fifo more than once with code like: using (var f = new FileStream ("/dev/zero", FileMode.Open)) { ... } using (var f = new FileStream ("/dev/zero", FileMode.Open)) { ... } --- mono/io-layer/io.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mono/io-layer/io.c b/mono/io-layer/io.c index 4fe2e248be7..ec08549a301 100644 --- a/mono/io-layer/io.c +++ b/mono/io-layer/io.c @@ -1037,8 +1037,11 @@ static void console_close (gpointer handle, gpointer data) g_free (console_handle->filename); - if (fd > 2) + if (fd > 2) { + if (console_handle->share_info) + _wapi_handle_share_release (console_handle->share_info); close (fd); + } } static WapiFileType console_getfiletype(void) @@ -1159,6 +1162,9 @@ static void pipe_close (gpointer handle, gpointer data) /* No filename with pipe handles */ + if (pipe_handle->share_info) + _wapi_handle_share_release (pipe_handle->share_info); + close (fd); } -- 2.11.4.GIT