Subj : Re: Is std::cerr thread safe To : comp.programming.threads From : Joe Seigh Date : Wed Jul 20 2005 03:48 pm nin234@yahoo.com wrote: > I was under the impression that std::cerr, cout etc were multi thread > safe. I recently changed the logging utility of our product ( a daemon > running on linux (RHEL) to use std::cerr instead of printf and it > produces garbled output to the log file. > What is the best approach to make it thread safe? > Should I use some sort of wrapper class? > printf to stdout or fprintf to stderr? Though I not sure it makes any difference. By garbled output I assume you mean interleaved or mixed together output. There no guarantee of atomicity on i/o. You should probably use a lock for output you want to appear together and not get intermixed with other output. -- Joe Seigh When you get lemons, you make lemonade. When you get hardware, you make software. .