On Sat 31/Jan/2015 13:55:24 +0100 Sam Varshavchik wrote:
> Alessandro Vesely writes:
>>
>> I have something like so:
>>
>> vfprintf(stderr, fmt, ap);
>> va_end(ap);
>> fputc('\n', stderr);
>>
>> That "INFO:" arrived from a sibling process. They both inherit fd 2 as a
>> pipe
>> to courierfilter. If courierfilter had seen "INFO:" at the beginning of a
>> line
>> it would have interpreted it as a severity code. But, even if stderr is
>> line-buffered, two processes can happen to flush their buffers
>> simultaneously.
>
> Each flush is atomic. Somewhere buried in the man pages is a guarantee that if
> a write() to a pipe is below a certain size, it is guaranteed to be atomic,
> and
> won't get comingled with anything else that writes to the same pipe.
That's right what I was hoping. I found the following in pipe(7):
POSIX.1-2001 says that write(2)s of less than PIPE_BUF bytes must be
atomic: the output data is written to the pipe as a contiguous
sequence. Writes of more than PIPE_BUF bytes may be nonatomic: the
kernel may interleave the data with data written by other processes.
POSIX.1-2001 requires PIPE_BUF to be at least 512 bytes. (On Linux,
PIPE_BUF is 4096 bytes.)
> If stderr is line-buffered, these short log lines should not get intermingled.
I thought it was line buffered, but I was wrong. setbuf(3) says "stderr is
always unbuffered by default". Calling setlinebuf(stderr) should fix that.
Thanks for the hint
Ale
--
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
courier-users mailing list
[email protected]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users