From 3e3d964b8581ee68c2efcd7c46d78c693dcb7b79 Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Thu, 16 Jun 2005 01:01:38 +0000 Subject: Create temp file in $TMPDIR instead of $TMP, and warn when creation failed --- Packdrakeng.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Packdrakeng.pm b/Packdrakeng.pm index f46c2b6..ecffd8e 100644 --- a/Packdrakeng.pm +++ b/Packdrakeng.pm @@ -29,14 +29,17 @@ my ($toc_header, $toc_footer) = sub tempfile { my ($count, $fname, $handle) = (0, undef, undef); do { - ++$count > 10 and return (undef, undef); + ++$count > 10 and do { + warn "Can't create temporary file"; + return (undef, undef); + }; $fname = sprintf("%s/packdrakeng.%s.%s", - $ENV{TMP} || '/tmp', + $ENV{TMPDIR} || '/tmp', $$, # Generating an random name join("", map { $_=rand(51); $_ += $_ > 25 && $_ < 32 ? 91 : 65 ; chr($_) } (0 .. 4))); - } while ( ! sysopen($handle, $fname, O_WRONLY | O_APPEND | O_CREAT)); - ($handle, $fname) + } while !sysopen($handle, $fname, O_WRONLY | O_APPEND | O_CREAT); + return ($handle, $fname); } # File::Path hack to not require it -- cgit v1.2.1