summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2013-05-20 17:31:18 +0000
committerjilles <jilles@FreeBSD.org>2013-05-20 17:31:18 +0000
commitea9572e1d0012ff80f61493b67ba20024b68d303 (patch)
treeea0d497bd3d5cf917334452542e753b2407bcd31 /tools
parentc80fb8a3c577778392b492acba6db1c21a35a030 (diff)
downloadFreeBSD-src-ea9572e1d0012ff80f61493b67ba20024b68d303.zip
FreeBSD-src-ea9572e1d0012ff80f61493b67ba20024b68d303.tar.gz
popen(): Add 'e' mode character to set close-on-exec on the new fd.
If 'e' is used, the kernel must support the recently added pipe2() system call. The use of pipe2() with O_CLOEXEC also fixes race conditions between concurrent popen() calls from different threads, even if the close-on-exec flag on the fd of the returned FILE is later cleared (because popen() closes all file descriptors from earlier popen() calls in the child process). Therefore, this approach should be used in all cases when pipe2() can be assumed present. The old version of popen() rejects "re" and "we" but treats "r+e" like "r+".
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/lib/libc/gen/test-popen.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/regression/lib/libc/gen/test-popen.c b/tools/regression/lib/libc/gen/test-popen.c
index b1ae295..bf301d2 100644
--- a/tools/regression/lib/libc/gen/test-popen.c
+++ b/tools/regression/lib/libc/gen/test-popen.c
@@ -70,10 +70,10 @@ main(int argc, char *argv[])
FILE *fp, *fp2;
int i, j, status;
const char *mode;
- const char *allmodes[] = { "r", "w", "r+" };
- const char *rmodes[] = { "r", "r+" };
- const char *wmodes[] = { "w", "r+" };
- const char *rwmodes[] = { "r+" };
+ const char *allmodes[] = { "r", "w", "r+", "re", "we", "r+e", "re+" };
+ const char *rmodes[] = { "r", "r+", "re", "r+e", "re+" };
+ const char *wmodes[] = { "w", "r+", "we", "r+e", "re+" };
+ const char *rwmodes[] = { "r+", "r+e", "re+" };
char buf[80];
struct sigaction act, oact;
OpenPOWER on IntegriCloud