ralphlange / procServ

Wrapper to start arbitrary interactive commands in the background, with telnet or Unix domain socket access to stdin/stdout
GNU General Public License v3.0
23 stars 23 forks source link

Close logfile FD for child processes #62

Closed gitwart closed 10 months ago

gitwart commented 10 months ago

When the child processes are spawned, they inherit the logfile file descriptor. If the procserv logs are rotated using the logrotate utility, then the child processes still have a open file handle on the original logfile before it gets rotated. This prevents the kernel from freeing up the space used even though the original logfile has been deleted. Over time, or with large logfiles, this can result in a lot of phantom space being used up in the log directory.

This PR closes the logfile file descriptor before exec()-ing the child processes, allowing the logfile to be rotated and cleaned up by the kernel.

ralphlange commented 10 months ago

Good catch!! Thanks a lot.