Reputation: 13849
I need to append information into a given file from a shared lib I wrote in C in Solaris. What would be the safest way to open the file in a shared way for writing ? Being a shared lib I assume there's a risk two instances try to write to the file simultaneously.
Thanks in advance
Upvotes: 0
Views: 156
Reputation: 409442
Two processes writing to the same file will, sooner or later, result in a garbled file. If you have access to both the library (which it seems you do) and the application, then you can protect all writes to the file with flock
calls.
Upvotes: 1