Re: single instance of multilog for multiple processes

Daryl Tester <[email protected]> Mon, 21 Sep 2009 22:34:04 +0930
Newsgroups gmane.comp.djb.syslog
Message-ID <[email protected]>
Richard Lucassen wrote:

> "man fifo" is not clear enough about this matter. The question is:
> where is the limit? Is it a block of 4096 bytes?

There are two limits as such - one is PIPE_BUF, which under Linux
(well, the one I'm running) is defined in <linux/limits.h> as 4096
characters.  The other limit is more of an issue than limit - the
write() to pipe has to be atomic.  In my aforementioned issue I had
some concurrent shell scripts being supervised.  Despite preformatting
the print strings to echo as one entire quoted string, strace showed
bash was splitting up the writes and thus allowing other log messages
to get interleaved.  I solved the problem by not using bash :-/.

> I just write lines no longer than let's say 80 to 100 charachters
> (including the timestamp) so I presume there will be no problem.

So long as you write it in one operation then it shouldn't be
an issue  e.g. if under C -

/* Note cunning ignorance of return value */
write(1, "hi there\n", strlen("hi there\n"));

If you split the string into several writes, that's when the
opportunity for mischief arises.

> And how would you merge two outputs from two separate multilog
> processes into file. Using a postprocessor?

If you have timestamps, then man (1) sort is your friend.

> I could also use "setlock" to lock the fifo for writing.

That would work, but then it wouldn't be concurrent ...

> And 

And?  Therefore?  Nevertheless?  But?  :-)


-- 
Regards,
  Daryl Tester

"Scheme is an exotic sports car. Fast. Manual transmission. No radio.
 Common Lisp is Howl's Moving Castle."
  -- Steve Yegge, comparing Lisp families to cars.