From b7561fc9bc645b8c7e0e9ebbb29349113cb716c1 Mon Sep 17 00:00:00 2001 From: Brian Fraser Date: Tue, 21 Jan 2014 22:45:17 -0300 Subject: 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. --- perlio.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'perlio.c') 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) -- cgit v1.2.1