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