annotate lib/openat-die.c @ 17363:5a51fb7777a9

sys_select, sys_time: port 2013-01-30 Solaris 2.6 fix to Cygwin Problem reported by Marco Atzeri in <http://lists.gnu.org/archive/html/bug-gnulib/2013-03/msg00000.html>. * lib/sys_select.in.h [HAVE_SYS_SELECT_H && _CYGWIN_SYS_TIME_H]: Simply delegate to the system <sys/select.h> in this case too. Also, pay attention to _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H only if OSF/1, since otherwise Cygwin breaks, and it doesn't seem to be needed on Solaris either. * lib/sys_time.in.h [_CYGWIN_SYS_TIME_H]: Simply delgate to the system <sys/time.h> in this case.
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 19 Mar 2013 09:08:47 -0700
parents e542fd46ad6f
children 344018b6e5d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6272
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
1 /* Report a save- or restore-cwd failure in our openat replacement and then exit.
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
2
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 16201
diff changeset
3 Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc.
6272
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
4
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 7302
diff changeset
5 This program is free software: you can redistribute it and/or modify
6272
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 7302
diff changeset
7 the Free Software Foundation; either version 3 of the License, or
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 7302
diff changeset
8 (at your option) any later version.
6272
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
9
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
13 GNU General Public License for more details.
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
14
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 7302
diff changeset
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
6272
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
17
7302
8a1a9361108c * _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents: 6322
diff changeset
18 #include <config.h>
6272
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
19
10647
038e7a58c9c8 openat-die.c: avoid 'no previous prototype' warning
Jim Meyering <meyering@redhat.com>
parents: 9309
diff changeset
20 #include "openat.h"
038e7a58c9c8 openat-die.c: avoid 'no previous prototype' warning
Jim Meyering <meyering@redhat.com>
parents: 9309
diff changeset
21
6272
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
22 #include <stdlib.h>
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
23
14271
b4cc3c41ca79 libposix: Add _HEADERS primaries to posix modules.
Bruce Korb <bkorb@gnu.org>
parents: 14079
diff changeset
24 #ifndef GNULIB_LIBPOSIX
14379
2330aac2ae54 maint: adjust cpp indentation to reflect nesting depth
Jim Meyering <meyering@redhat.com>
parents: 14271
diff changeset
25 # include "error.h"
14271
b4cc3c41ca79 libposix: Add _HEADERS primaries to posix modules.
Bruce Korb <bkorb@gnu.org>
parents: 14079
diff changeset
26 #endif
b4cc3c41ca79 libposix: Add _HEADERS primaries to posix modules.
Bruce Korb <bkorb@gnu.org>
parents: 14079
diff changeset
27
6272
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
28 #include "exitfail.h"
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
29
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
30 #include "gettext.h"
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
31 #define _(msgid) gettext (msgid)
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
32
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
33 void
10668
26ed9785f377 Avoid a compilation error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 10647
diff changeset
34 openat_save_fail (int errnum)
6272
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
35 {
14271
b4cc3c41ca79 libposix: Add _HEADERS primaries to posix modules.
Bruce Korb <bkorb@gnu.org>
parents: 14079
diff changeset
36 #ifndef GNULIB_LIBPOSIX
10668
26ed9785f377 Avoid a compilation error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 10647
diff changeset
37 error (exit_failure, errnum,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12027
diff changeset
38 _("unable to record current working directory"));
14271
b4cc3c41ca79 libposix: Add _HEADERS primaries to posix modules.
Bruce Korb <bkorb@gnu.org>
parents: 14079
diff changeset
39 #endif
15403
73b69bb944ff * lib/openat-die.c (openat_save_fail): Modernize comment.
Paul Eggert <eggert@cs.ucla.edu>
parents: 14379
diff changeset
40 /* _Noreturn cannot be applied to error, since it returns
6272
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
41 when its first argument is 0. To help compilers understand that this
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
42 function does not return, call abort. Also, the abort is a
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
43 safety feature if exit_failure is 0 (which shouldn't happen). */
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
44 abort ();
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
45 }
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
46
12027
b10ac4488b07 openat: allow return of fd 0
Eric Blake <ebb9@byu.net>
parents: 11395
diff changeset
47
b10ac4488b07 openat: allow return of fd 0
Eric Blake <ebb9@byu.net>
parents: 11395
diff changeset
48 /* Exit with an error about failure to restore the working directory
b10ac4488b07 openat: allow return of fd 0
Eric Blake <ebb9@byu.net>
parents: 11395
diff changeset
49 during an openat emulation. The caller must ensure that fd 2 is
b10ac4488b07 openat: allow return of fd 0
Eric Blake <ebb9@byu.net>
parents: 11395
diff changeset
50 not a just-opened fd, even when openat_safer is not in use. */
b10ac4488b07 openat: allow return of fd 0
Eric Blake <ebb9@byu.net>
parents: 11395
diff changeset
51
6272
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
52 void
10668
26ed9785f377 Avoid a compilation error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 10647
diff changeset
53 openat_restore_fail (int errnum)
6272
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
54 {
14271
b4cc3c41ca79 libposix: Add _HEADERS primaries to posix modules.
Bruce Korb <bkorb@gnu.org>
parents: 14079
diff changeset
55 #ifndef GNULIB_LIBPOSIX
10668
26ed9785f377 Avoid a compilation error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 10647
diff changeset
56 error (exit_failure, errnum,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12027
diff changeset
57 _("failed to return to initial working directory"));
14271
b4cc3c41ca79 libposix: Add _HEADERS primaries to posix modules.
Bruce Korb <bkorb@gnu.org>
parents: 14079
diff changeset
58 #endif
6272
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
59
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
60 /* As above. */
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
61 abort ();
3baa574549ae * modules/openat (Files): Add lib/openat-die.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
62 }