[LC++]IOStreams and forking.
filiond at videotron.ca
Wed Nov 6 02:29:01 UTC 2002
Jack Lloyd wrote:
> I doubt any standard has been defined; ISO C++ doesn't mention threads, and
> the thread/IPC standards (POSIX, Unix98, etc) don't mention C++. Basically
> "it depends". And as you have found, relying on it is a bad idea. :(
> There are a few other options that come to mind, which may or may not be
> Use threads instead of fork()
> Use syslog()
> Write a log daemon (or reuse one somebody else has written) and talk to
> it over a Unix domain socket (preferably wrapped inside a function ala
> Keep the logging file open as a Unix file descriptor.
> BTW, be careful about multiple processes writing to the file at once: they
> could easily overlap in their outputs, etc. Consider fcntl() locking, or a
> central log server, to solve that problem. HTH.
> On Tue, 5 Nov 2002, David wrote:
Thanks for the info.
After sending the email to the list, I found a core file. Turned out each
child was crashing just before the statment that wrote to the file. Doh!
Now that I have output, the next step will be making sure the output
doesn't overlap (as you pointed out).
Registerd (Slackware) linux user #195143
"Yes, it's manly, but let's face it, so is bungee-jumping with the
cord tied to your testicles." -- Linus Torvalds
More information about the tuxCPProgramming