This patch causes Memtrace to turn itself off if the PID changes, so that if tracing is active across a call to fork then the child process writes no further events, instead of risking corruption of the trace file with two concurrent writers.
The implementation reuses the existing mechanism for disabling Memtrace if flushing fails: in the existing code, if any tracing operation raises an exception then a backtrace is printed to stderr and future tracing is disabled. The only difference here is that if tracing is disabled due to a PID change, no message is printed to stderr.
This patch causes Memtrace to turn itself off if the PID changes, so that if tracing is active across a call to fork then the child process writes no further events, instead of risking corruption of the trace file with two concurrent writers.
The implementation reuses the existing mechanism for disabling Memtrace if flushing fails: in the existing code, if any tracing operation raises an exception then a backtrace is printed to stderr and future tracing is disabled. The only difference here is that if tracing is disabled due to a PID change, no message is printed to stderr.