Mercurial > gnulib
annotate lib/spawn_faction_addopen.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 |
rev | line source |
---|---|
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16257
diff
changeset
|
1 /* Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. |
10509
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
2 This file is part of the GNU C Library. |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 (at your option) any later version. |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 #include <config.h> |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 /* Specification. */ |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 #include <spawn.h> |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 #include <errno.h> |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 #include <unistd.h> |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
25 #if !_LIBC |
10584 | 26 # define __sysconf(open_max) getdtablesize () |
10509
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 #endif |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 |
16257
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
29 #if !HAVE_WORKING_POSIX_SPAWN |
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
30 # include "spawn_int.h" |
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
31 #endif |
10509
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 /* Add an action to FILE-ACTIONS which tells the implementation to call |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
34 'open' for the given file during the 'spawn' call. */ |
10509
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 int |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *file_actions, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10584
diff
changeset
|
37 int fd, const char *path, int oflag, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10584
diff
changeset
|
38 mode_t mode) |
16257
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
39 #undef posix_spawn_file_actions_addopen |
10509
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
40 { |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
41 int maxfd = __sysconf (_SC_OPEN_MAX); |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 /* Test for the validity of the file descriptor. */ |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
44 if (fd < 0 || fd >= maxfd) |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 return EBADF; |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 |
16257
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
47 #if HAVE_WORKING_POSIX_SPAWN |
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
48 return posix_spawn_file_actions_addopen (file_actions, fd, path, oflag, mode); |
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
49 #else |
10509
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
50 /* Allocate more memory if needed. */ |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
51 if (file_actions->_used == file_actions->_allocated |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
52 && __posix_spawn_file_actions_realloc (file_actions) != 0) |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
53 /* This can only mean we ran out of memory. */ |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
54 return ENOMEM; |
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
55 |
16257
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
56 { |
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
57 struct __spawn_action *rec; |
10509
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
58 |
16257
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
59 /* Add the new value. */ |
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
60 rec = &file_actions->_actions[file_actions->_used]; |
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
61 rec->tag = spawn_do_open; |
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
62 rec->action.open_action.fd = fd; |
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
63 rec->action.open_action.path = path; |
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
64 rec->action.open_action.oflag = oflag; |
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
65 rec->action.open_action.mode = mode; |
10509
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
66 |
16257
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
67 /* Account for the new entry. */ |
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
68 ++file_actions->_used; |
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
69 |
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
70 return 0; |
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
71 } |
a5001764146b
posix_spawn_file_actions_addopen: Work around Solaris 11 2011-11 bug.
Bruno Haible <bruno@clisp.org>
parents:
16235
diff
changeset
|
72 #endif |
10509
4b837b5f2c9a
New module 'posix_spawn_file_actions_addopen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
73 } |