]>
Commit | Line | Data |
---|---|---|
d6e0c2a6 UD |
1 | #include <fcntl.h> |
2 | #include <stdio.h> | |
3 | ||
4 | static int | |
5 | do_test (void) | |
6 | { | |
7 | int res = 0; | |
8 | ||
9 | FILE *fp = popen ("echo hello", "r"); | |
10 | if (fp == NULL) | |
11 | { | |
12 | puts ("first popen failed"); | |
13 | res = 1; | |
14 | } | |
15 | else | |
16 | { | |
17 | int fd = fileno (fp); | |
18 | if (fcntl (fd, F_GETFD) == FD_CLOEXEC) | |
19 | { | |
20 | puts ("first popen(\"r\") set FD_CLOEXEC"); | |
21 | res = 1; | |
22 | } | |
23 | ||
c1760eaf | 24 | pclose (fp); |
d6e0c2a6 UD |
25 | } |
26 | ||
27 | fp = popen ("echo hello", "re"); | |
28 | if (fp == NULL) | |
29 | { | |
30 | puts ("second popen failed"); | |
31 | res = 1; | |
32 | } | |
33 | else | |
34 | { | |
35 | int fd = fileno (fp); | |
36 | if (fcntl (fd, F_GETFD) != FD_CLOEXEC) | |
37 | { | |
38 | puts ("second popen(\"r\") did not set FD_CLOEXEC"); | |
39 | res = 1; | |
40 | } | |
41 | ||
c1760eaf | 42 | pclose (fp); |
d6e0c2a6 UD |
43 | } |
44 | ||
45 | return res; | |
46 | } | |
47 | ||
48 | #define TEST_FUNCTION do_test () | |
49 | #include "../test-skeleton.c" |