Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters
print() on closed filehandle w ith “Bad File Descri ptor”
 

Index | Next | Previous | View Flat


davidb_tai at hotmail

May 6, 2012, 4:41 PM


Views: 81
Permalink
print() on closed filehandle w ith “Bad File Descri ptor”

I have a tcp server in perl (revision 5.0 version 8 subversion 0) which use this subroutine to log in a file.



sub logger {

return if ($LOGFILE eq "") ;

my ($idt, $str) = @_ ;

unless( defined($str) ) {

$str = $idt ;

$idt = '' ;

}

my ($s,$m,$h,$J,$M,$A) = localtime(time()) ;

if(!open(OUT,">>$LOGFILE"))

{

warn "logger:error open [$LOGFILE]:[$!]\n";

return;

}

if (!printf OUT "%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d %s %s -> %s\n",

$A+1900, $M+1, $J, $h, $m, $s, $idt, $HOSTNAME, $str)

{

warn "logger:error print [$LOGFILE]:[$!]\n";

return;

}

if (!close(OUT))

{

warn "logger:error close [$LOGFILE]:[$!]\n";

return;

}

}



So there is simultaneous writing in this log file. Exceptionally , I have this error in STDERR:



printf() on closed filehandle

logger :error print [/my/path/logFile.LOG]:[Bad File Descriptor]



without any error on open!



How can I resolve this problem?
Thanks for your help!!!

Subject User Time
print() on closed filehandle w ith “Bad File Descri ptor” davidb_tai at hotmail May 6, 2012, 4:41 PM
    Re: print() on closed filehandle with “Bad File Descriptor” fawaka at gmail May 7, 2012, 1:21 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.