summaryrefslogtreecommitdiff
path: root/lib/close.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-10-27 13:45:04 +0200
committerAndy Wingo <wingo@pobox.com>2011-10-27 13:45:04 +0200
commit4938d3cb742de2a356586c55e5af32e193c5990b (patch)
treeb4bfe0fd26e102c5fa38ca9965bc4ebdbae8e3b4 /lib/close.c
parent9d013330154852bc2309947adaa30b32418642c0 (diff)
parent2be3feb17e5456bba71749e0e97adf45c32c4e0e (diff)
downloadguile-4938d3cb742de2a356586c55e5af32e193c5990b.tar.gz
Merge remote-tracking branch 'origin/stable-2.0'
Conflicts: GUILE-VERSION libguile/deprecated.c libguile/gc-malloc.c module/language/tree-il/peval.scm
Diffstat (limited to 'lib/close.c')
-rw-r--r--lib/close.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/lib/close.c b/lib/close.c
index 378c4f145..e8a1ed5cb 100644
--- a/lib/close.c
+++ b/lib/close.c
@@ -19,18 +19,45 @@
/* Specification. */
#include <unistd.h>
+#include <errno.h>
+
#include "fd-hook.h"
+#include "msvc-inval.h"
+
+#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 (close, fd);
+ int retval = execute_all_close_hooks (close_nothrow, fd);
#else
- int retval = close (fd);
+ int retval = close_nothrow (fd);
#endif
#if REPLACE_FCHDIR