Closing a strange handle in some Linux programs

At the same time, when some linux daemons (such as sendmail) suppress some of them, I noticed that some of them will call close () for several descriptors (usually from 3 to 255) at the beginning. Is this done on purpose or is it some kind of side effect of doing something else?

+3
source share
1 answer

This is usually done as part of the process creation by the daemon.

All file descriptors are closed, so a long daemon does not require extra resources. For example, if the daemon had to inherit the open file, and the daemon did not close it, then the file could not be deleted (the storage for it would remain allocated until it was closed), and the file system in which the file is located cannot be unmounted.

The process demonstration will also take a number of other actions, but these actions are beyond the scope of this issue.

+3
source

Source: https://habr.com/ru/post/1777407/


All Articles