This source file includes following definitions.
- posix_spawn_file_actions_addclose
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include <config.h>
18
19
20 #include <spawn.h>
21
22 #include <errno.h>
23 #include <unistd.h>
24
25 #if !_LIBC
26 # define __sysconf(open_max) getdtablesize ()
27 #endif
28
29 #if REPLACE_POSIX_SPAWN
30 # include "spawn_int.h"
31 #endif
32
33
34
35 int
36 posix_spawn_file_actions_addclose (posix_spawn_file_actions_t *file_actions,
37 int fd)
38 #undef posix_spawn_file_actions_addclose
39 {
40 int maxfd = __sysconf (_SC_OPEN_MAX);
41
42
43 if (fd < 0 || fd >= maxfd)
44 return EBADF;
45
46 #if !REPLACE_POSIX_SPAWN
47 return posix_spawn_file_actions_addclose (file_actions, fd);
48 #else
49
50 if (file_actions->_used == file_actions->_allocated
51 && __posix_spawn_file_actions_realloc (file_actions) != 0)
52
53 return ENOMEM;
54
55 {
56 struct __spawn_action *rec;
57
58
59 rec = &file_actions->_actions[file_actions->_used];
60 rec->tag = spawn_do_close;
61 rec->action.open_action.fd = fd;
62
63
64 ++file_actions->_used;
65
66 return 0;
67 }
68 #endif
69 }