What can cause a print error in perl?

I have a long script that opens the file every hour, prints it and closes the file. I rarely met very rarely, the print fails, not because I check the status of the print itself, but rather because there are no missing entries in the file until the system is rebooted!

I set a trap for file failures and write a message to syslog when this happens, and I don't see any open crashes, so now I assume that it might be a print failure. I do not catch the failures of the press, which, as I suspect, most people do not, but now I am going to update this print.

Meanwhile, my question is, does anyone know what types of situations can cause a print statement to fail when there is a lot of disk storage and there is no competition for a file that was successfully opened in add mode?

+7
source share
1 answer

You may have low memory (ENOMEM) or a file size limit (E2BIG or SIGXFSZ). You may have an old-fashioned I / O error (EIO). You may have a race condition if the script runs at the same time or if the file is accessed via NFS. And, of course, you might have an error in the expression whose value you are typing.

The exotic reason I once saw is that a CPU heatsink failure could cause sprintf to crash, causing some unexpected results, including writing garbage to file descriptors.

Finally, let me remind you that printing often writes its data to the I / O buffer. That means two things. (1) You also need to check the result of close (). (2) If you print, but do not immediately close () or flush (), then your data may be buffered and not actually written until much later (or not at all if the process dies horribly).

+7
source

All Articles