X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fclose.c;h=f620e54bba3520adc5a4463edb9ffeae9bf07ce8;hb=8866a241ddbf4a459347b7147e325f539e4c07fe;hp=9b050668a8ba9dc3e6b936ec83843ed48910fa34;hpb=59a539f3e601f4639e67d9a6d2a20c9450e642f4;p=gnulib.git diff --git a/lib/close.c b/lib/close.c index 9b050668a..f620e54bb 100644 --- a/lib/close.c +++ b/lib/close.c @@ -1,5 +1,5 @@ /* close replacement. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2013 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 @@ -19,24 +19,48 @@ /* Specification. */ #include -#if GNULIB_SYS_SOCKET -# include -#endif +#include + +#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 HAVE__GL_CLOSE_FD_MAYBE_SOCKET - int retval = _gl_close_fd_maybe_socket (fd); +#if WINDOWS_SOCKETS + int retval = execute_all_close_hooks (close_nothrow, fd); #else - int retval = close (fd); + int retval = close_nothrow (fd); #endif -#ifdef FCHDIR_REPLACEMENT +#if REPLACE_FCHDIR if (retval >= 0) _gl_unregister_fd (fd); #endif