You are not logged in.

#1 2014-05-22 20:59:30

jernst
Member
From: Silicon Valley
Registered: 2014-03-04
Posts: 290
Website

failing to create temp file in Perl cgi script

This used to work, perhaps before the Apache 2.4 upgrade?

From the httpd error log:

 AH01215: Error in tempfile() using template /tmp/XXXXXXXXXX: Could not create temp file /tmp/4VmuZsw3Wt: No such file or directory at...

Here's the offending code:

#!/usr/bin/perl

use strict;
use warnings;
use File::Temp;
use CGI;

my $q = new CGI();
print $q->header();

print "Hi mom\n";

my( $foo, $bar ) = File::Temp::tempfile();
print $foo "Test content\n";
close( $foo );

print "Hi dad\n";
1;

If invoked from the command-line, it works as intended. Tried as users me, root and http (the Apache user).

If run as CGI script, I get this:

Hi mom

then it aborts with an HTTP 500, and emits the above message in the error log.

Before anybody asks:

drwxrwxrwt 7 root root 240 May 22 20:51 /tmp

The Apache configuration has this, which /some/path/cgi contains my above script.

ScriptAlias "/cgi"   /some/path/cgi

Baffled ...

Offline

#2 2014-05-22 21:19:51

jernst
Member
From: Silicon Valley
Registered: 2014-03-04
Posts: 290
Website

Re: failing to create temp file in Perl cgi script

Restarting Apache fixed the issue. Ran out of file descriptors perhaps?

The question is: will it happen again?

Last edited by jernst (2014-05-22 21:20:12)

Offline

Board footer

Powered by FluxBB