+static uintptr_t next_thread_num = 1;
+
+static OS_THREAD_SPECIFIC_PTR(void)
+thread_num;
+
+void LocalWriter::checkProcessId(void) {
+ if (m_file->isOpened() &&
+ os::getCurrentProcessId() != pid) {
+ // We are a forked child process that inherited the trace file, so
+ // create a new file. We can't call any method of the current
+ // file, as it may cause it to flush and corrupt the parent's
+ // trace, so we effectively leak the old file object.
+ m_file = File::createSnappy();
+ // Don't want to open the same file again
+ os::unsetEnvironment("TRACE_FILE");
+ open();
+ }
+}