Re: multiple streams to the same file



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.
.



Relevant Pages

  • Re: My NFL pics for the weekend
    ... It takes balls to go out on a limb, and to be fair I only saw ... >>   This guy is the WORST sports bettor in the history of sports. ... > NONE of my picks are locks so please don't take them as such. ...
    (rec.gambling.poker)
  • Re: list-locks to deduce filenames
    ... the basic command   READU   can assert ... probably every flavor of pick probably ... been thinking of locks as solely to protect old items. ... to clutter live files with test items. ...
    (comp.databases.pick)
  • Re: Do you do?
    ...      Make it as simple as possible, ... Or he has a hotel on the ocean and is thinking of changing 300 locks, ... I got a call about painting 1 lousy door, It turned out to be 130 ... commercial jobs where you can eat for years. ...
    (alt.home.repair)
  • Re: Q. Robust Reader-Writer lock (across unrelated processes?)
    ... Does this not allow for locks to be created in shared memory and ...
    (comp.unix.programmer)
  • Re: POLL -- are you improving the world, or making it worse?
    ...   Here ... writer, on a writing blog, who feels the idiotic need to exclaim: ... But, then I lost it. ... proceeded by "these are our endless listacompalessed [meaning endless ...
    (misc.writing)