summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2017-12-19 19:00:07 +0000
committerZefram <zefram@fysh.org>2017-12-22 16:30:12 +0000
commit1cdb2692fbfca71c0b0f3302f522f6dc1f460664 (patch)
treed8dc5d8753afa27d5b1e28737cf9aeb68642d3be /doio.c
parentd333cbeb476c54aaf8f85ffdcfc187f23b4ea2ee (diff)
downloadperl-1cdb2692fbfca71c0b0f3302f522f6dc1f460664.tar.gz
Perl_my_mkstemp_cloexec() function
Like the other "_cloexec" I/O functions, this guarantees to return a file descriptor with FD_CLOEXEC set, and will set the flag atomically if possible.
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/doio.c b/doio.c
index 56615cdd90..d18e335a04 100644
--- a/doio.c
+++ b/doio.c
@@ -61,7 +61,7 @@
#include <signal.h>
void
-Perl_setfd_cloexec(pTHX_ int fd)
+Perl_setfd_cloexec(int fd)
{
assert(fd >= 0);
#if defined(HAS_FCNTL) && defined(F_SETFD) && defined(FD_CLOEXEC)
@@ -70,7 +70,7 @@ Perl_setfd_cloexec(pTHX_ int fd)
}
void
-Perl_setfd_inhexec(pTHX_ int fd)
+Perl_setfd_inhexec(int fd)
{
assert(fd >= 0);
#if defined(HAS_FCNTL) && defined(F_SETFD) && defined(FD_CLOEXEC)
@@ -221,6 +221,19 @@ Perl_PerlLIO_open3_cloexec(pTHX_ const char *file, int flag, int perm)
#endif
}
+int
+Perl_my_mkstemp_cloexec(char *templte)
+{
+ PERL_ARGS_ASSERT_MY_MKSTEMP_CLOEXEC;
+#if defined(O_CLOEXEC)
+ DO_ONEOPEN_EXPERIMENTING_CLOEXEC(
+ Perl_my_mkostemp(templte, O_CLOEXEC),
+ Perl_my_mkstemp(templte));
+#else
+ DO_ONEOPEN_THEN_CLOEXEC(Perl_my_mkstemp(templte));
+#endif
+}
+
#ifdef HAS_PIPE
int
Perl_PerlProc_pipe_cloexec(pTHX_ int *pipefd)