summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorBrian Fraser <fraserbn@gmail.com>2014-01-21 22:45:17 -0300
committerBrian Fraser <fraserbn@gmail.com>2014-01-21 22:45:17 -0300
commitb7561fc9bc645b8c7e0e9ebbb29349113cb716c1 (patch)
tree97d66776c5d59056b1cbfdf02e64bae84e68be35 /perlio.c
parent8a064057e2281eb2b0cca29e1f1046df752abfe1 (diff)
downloadperl-b7561fc9bc645b8c7e0e9ebbb29349113cb716c1.tar.gz
perlio.c, PerlIO_tmpfile: Fall back to cwd if we have no /tmp or $TMPDIR
With this, open($fh, undef) will now work on systems without a /tmp (or equivalent) where TMPDIR is not set.
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/perlio.c b/perlio.c
index 5d41e76c55..ec19bfe453 100644
--- a/perlio.c
+++ b/perlio.c
@@ -4971,6 +4971,12 @@ PerlIO_tmpfile(void)
/* else we try /tmp */
fd = mkstemp(tempname);
}
+ if (fd < 0) {
+ /* Try cwd */
+ sv = newSVpvs(".");
+ sv_catpv(sv, tempname + 4);
+ fd = mkstemp(SvPVX(sv));
+ }
if (fd >= 0) {
f = PerlIO_fdopen(fd, "w+");
if (f)