~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to lib/close.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* close replacement.
2
 
   Copyright (C) 2008-2011 Free Software Foundation, Inc.
 
2
   Copyright (C) 2008-2012 Free Software Foundation, Inc.
3
3
 
4
4
   This program is free software: you can redistribute it and/or modify
5
5
   it under the terms of the GNU General Public License as published by
19
19
/* Specification.  */
20
20
#include <unistd.h>
21
21
 
 
22
#include <errno.h>
 
23
 
22
24
#include "fd-hook.h"
 
25
#include "msvc-inval.h"
 
26
 
 
27
#undef close
 
28
 
 
29
#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
 
30
static int
 
31
close_nothrow (int fd)
 
32
{
 
33
  int result;
 
34
 
 
35
  TRY_MSVC_INVAL
 
36
    {
 
37
      result = close (fd);
 
38
    }
 
39
  CATCH_MSVC_INVAL
 
40
    {
 
41
      result = -1;
 
42
      errno = EBADF;
 
43
    }
 
44
  DONE_MSVC_INVAL;
 
45
 
 
46
  return result;
 
47
}
 
48
#else
 
49
# define close_nothrow close
 
50
#endif
23
51
 
24
52
/* Override close() to call into other gnulib modules.  */
25
53
 
26
54
int
27
55
rpl_close (int fd)
28
 
#undef close
29
56
{
30
57
#if WINDOWS_SOCKETS
31
 
  int retval = execute_all_close_hooks (close, fd);
 
58
  int retval = execute_all_close_hooks (close_nothrow, fd);
32
59
#else
33
 
  int retval = close (fd);
 
60
  int retval = close_nothrow (fd);
34
61
#endif
35
62
 
36
63
#if REPLACE_FCHDIR