c - How to assign a soft limit to a file size in code -
i looking on unix man page of write . http://linux.die.net/man/3/write
in application log errors, warning , process related minor information, written in log file. want if file size becomes greater 1gb , process should no more able write logfile . see man page tells can achieved , write fails .
if write() requests more bytes written there room (for example, process' file size limit or physical end of medium), many bytes there room shall written.
does requires ulimit related changes ? not want apply @ server level process level application , unnecessary not fill disk size completely. suggestion should here ? believe solution equally apply c++.
you can use gnu resource usage functions set , per process limits. gnu resource usage functions on other hand can log rotation based on size. if log size exceeds more limit create tar file of old log , start writing new log.
Comments
Post a Comment