X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=lib%2Fclose.c;h=01c326a28c74cc31188a23abe1be958dc90d2f27;hb=92249085071a973e2c0621b0415b93d2e48bb00d;hp=afa8f64058cb9dd16f1135bcf06131993c2c221a;hpb=dc0ab95dbae38577efebe2283fc9b76e92ef4233;p=debian%2Fgzip
diff --git a/lib/close.c b/lib/close.c
index afa8f64..01c326a 100644
--- a/lib/close.c
+++ b/lib/close.c
@@ -1,5 +1,5 @@
/* close replacement.
- Copyright (C) 2008-2010 Free Software Foundation, Inc.
+ Copyright (C) 2008-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,25 +12,54 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see . */
+ along with this program. If not, see . */
#include
/* Specification. */
#include
-#include "close-hook.h"
+#include
+
+#include "fd-hook.h"
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+#endif
+
+#undef close
+
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+static int
+close_nothrow (int fd)
+{
+ int result;
+
+ TRY_MSVC_INVAL
+ {
+ result = close (fd);
+ }
+ CATCH_MSVC_INVAL
+ {
+ result = -1;
+ errno = EBADF;
+ }
+ DONE_MSVC_INVAL;
+
+ return result;
+}
+#else
+# define close_nothrow close
+#endif
/* Override close() to call into other gnulib modules. */
int
rpl_close (int fd)
-#undef close
{
#if WINDOWS_SOCKETS
- int retval = execute_all_close_hooks (fd);
+ int retval = execute_all_close_hooks (close_nothrow, fd);
#else
- int retval = close (fd);
+ int retval = close_nothrow (fd);
#endif
#if REPLACE_FCHDIR