Re: question about forked processes writing to the same file




axel@xxxxxxxxxxxxxxxxxxxxxx wrote:
> it_says_BALLS_on_your_forehead <simon.chao@xxxxxxxxx> wrote:
>
> > axel@xxxxxxxxxxxxxxxxxxxxxx wrote:
> >> >> Thanks for sharing. Then the lock is probably not redundant, as I
> >> >> previously was suspecting, even if I'm doing it as well.
>
> >> > yeah, i don't think it's an issue when you're appending small strings
> >> > to a file, but they should make file locking default, don't you think?!
> >> > :-)
>
> >> > when *wouldn't* you want to lock a file when writing?
>
> >> Simple... when you have several Apache processes dealing with
> >> web requests more or less at the same time and wanting to just
> >> append to a log file. I was a bit worried about this at one
> >> time using Solaris but I investigated and found it not to
> >> be a problem. I suspect that BSD and Linux work in a similar
> >> manner... I cannot answer for any other operating systems.
>
> > actually, i had several processes appending to the same log file and
> > came across records that had spliced entries. this was the very problem
> > of which i spoke, and why i ended up needing to explicitly flock.
>
> Which operating system were you using? I never ran across this problem
> using Solaris.
>
> Axel

SunOS 5.8

.