M
M
Maxim Dyachenko2013-05-01 12:04:04
PHP
Maxim Dyachenko, 2013-05-01 12:04:04

Automatic closing of files

Recently, disk space often began to disappear, and appear back after restarting Apache.
The hoster insists that this is due to the fact that somewhere in some php scripts the files are not closed, and they hang until the reboot. Perhaps the support did not express himself very clearly and it is not the place that disappears, but the descriptors. Not the point.

From the thought of looking for such an error in scripts, it’s not even the fact that the scripts were written by direct hands that stops me, but the persistent thought that the files SHOULD be closed automatically at the end of the script.

Unfortunately, I did not find confirmation of this in the documentation, but it seems so natural to me ... In my opinion, even exit in the handler from register_shutdown_function should not cancel this.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nazar Mokrinsky, 2013-05-01
@nazarpc

Stops what SHOULD, and spur on what WILL NOT.
And the second should outweigh.
If it fits, use file_get_contents() / file_put_contents(), then there will be no issues with this, but if you open a file with fopen(), then please close it.

F
facha, 2013-05-01
@facha

Do you have shell access? Can you see what's open? For example, like this:

ls -l /proc/11111/fd

11111 is the pid of the process.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question