Re: multiple streams to the same file
- From: "roger.sen@xxxxxxxxx" <roger.sen@xxxxxxxxx>
- Date: Wed, 20 Feb 2008 03:51:32 -0800 (PST)
On 20 feb, 05:57, Evan Monroig <slj-ev...@xxxxxxxxxxxxx> wrote:
Thanks to both of you for the replies. This is not so simple that I
actually thought. I didn't know about O_APPEND, this is nice to know.
Since I use a lock before writing to the stream, with this approach I
conclude that the threads will not interfere with each other, and will
properly append to the file if it is open with O_APPEND, but different
processes might interfere with each other.
So this leaves the problem of different processes writing to the file at
the same time, with writes not being atomic. From your discussions my
options are:
1. do nothing => the log file will not break as long as I don't start
two SBCLs and no other application writes to the file.
2. ensure that I perform atomic writes (but as David said it requires
cooperation from the implementation)
3. use file locks => won't break as long as no other application that
doesn't understand my locks writes to the file.
4. use OS-level locks => then I have to close the file and reopen it at
each write if I have different processes.
I think that I will go for (1) since in my case it doesn't make sense to
use the same log file for two applications. I might combine it with (3)
just in case, since that looks quite straightforward to implement.
If you're in a unix environment, what about delegating the logging
task to syslog ().
You can interface to syslog unix client library quickly with CFFI or
implement the basic BSD protocol. It is incredibly simple.
Regards,
rogersm.
.
- Follow-Ups:
- Re: multiple streams to the same file
- From: Evan Monroig
- Re: multiple streams to the same file
- References:
- multiple streams to the same file
- From: Evan Monroig
- Re: multiple streams to the same file
- From: David Lichteblau
- Re: multiple streams to the same file
- From: Richard M Kreuter
- Re: multiple streams to the same file
- From: David Lichteblau
- Re: multiple streams to the same file
- From: Richard M Kreuter
- Re: multiple streams to the same file
- From: Evan Monroig
- multiple streams to the same file
- Prev by Date: Re: Paul Graham's Arc is released today... what is the long term impact?
- Next by Date: Re: λ notation
- Previous by thread: Re: multiple streams to the same file
- Next by thread: Re: multiple streams to the same file
- Index(es):
Relevant Pages
|