This source file includes following definitions.
- big_fd
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include <config.h>
18
19 #include <spawn.h>
20
21 #include "signature.h"
22 SIGNATURE_CHECK (posix_spawn_file_actions_addopen, int,
23 (posix_spawn_file_actions_t *, int,
24 const char *, int, mode_t));
25
26 #include <errno.h>
27 #include <fcntl.h>
28 #include <limits.h>
29 #include <unistd.h>
30
31 #include "macros.h"
32
33
34
35
36 static int
37 big_fd (void)
38 {
39 int fd = getdtablesize ();
40 #ifdef OPEN_MAX
41 if (fd < OPEN_MAX)
42 fd = OPEN_MAX;
43 #endif
44 return fd;
45 }
46
47 int
48 main (void)
49 {
50 posix_spawn_file_actions_t actions;
51
52 ASSERT (posix_spawn_file_actions_init (&actions) == 0);
53
54
55 {
56 errno = 0;
57 ASSERT (posix_spawn_file_actions_addopen (&actions, -1,
58 "foo", 0, O_RDONLY)
59 == EBADF);
60 }
61 {
62 int bad_fd = big_fd ();
63 errno = 0;
64 ASSERT (posix_spawn_file_actions_addopen (&actions, bad_fd,
65 "foo", 0, O_RDONLY)
66 == EBADF);
67 }
68
69 posix_spawn_file_actions_destroy (&actions);
70
71 return 0;
72 }