[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [LC++]IOStreams and forking.



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
useful:
  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
    syslog)
  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.

Regards,
  Jack

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


--
David Filion
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