in reply to The old inappropriate ioctl bugaboo again, in mod_perl2

Personally, I would try lexical filehandles instead of global filehandles, especially as you don't seem to be localizing FILE. If circumstances collude, you might or might not close the FILE filehandle for some other routine while you're doing your logging.

Alternatively, maybe it's a hardware problem and the device in question is (going) bad and has intermittent errors?