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

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -