how do utilities like logrotate work? i'm wondering about the underlying mechanics so that i can be comfortable putting it under a running service
-
Show this thread
-
so https://wiki.archlinux.org/index.php/Logrotate … mentions that logrotate renames the existing log file and makes a new empty file in the old place is there a risk of a race condition if the program writing to the log file is still running? seems like it could cause problems
1 reply 0 retweets 0 likesShow this thread -
Replying to @QuietMisdreavus
I believe the rename command / syscall is atomic, and open handles continue to point to the same file meaning there *should* not be any problems. Though I bet in practice there definitely can be. https://linux.die.net/man/2/rename
2 replies 1 retweet 4 likes -
Replying to @yoshuawuyts @QuietMisdreavus
yeah this is definitely the case. Usually doing something like a lock file then using rename to overwrite the original is a common use case, you need the guaranteed atomicity. I mean the only downside I could see is overwriting the state if two processes work on the same file.
1 reply 0 retweets 2 likes -
Replying to @mgattozzi @QuietMisdreavus
Somewhat related: I'd love to see a Rust port of https://github.com/mafintosh/fd-lock … to have access to cross-platform file locking.
1 reply 0 retweets 1 like -
Replying to @yoshuawuyts @QuietMisdreavus
Oh neat you can lock a file from the file descriptor itself?
2 replies 0 retweets 1 like
Yeah! -- Linux, Windows, MacOS all have this capability. I think in Rust this could be especially nice as I think we could apply an "AsRawFd" extension trait that would add a `lock` method to lock + a scope guard to unlock it 
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.