cupti-trace: finish a window that is open at process exit (leak the state, wait for the watcher)
This commit is contained in:
@@ -144,7 +144,8 @@ struct State {
|
||||
int winSeq = 0;
|
||||
std::string trigger, errPath;
|
||||
};
|
||||
State S;
|
||||
// leaked on purpose: the watcher thread may still be closing a window while the process exits and static destructors run
|
||||
State& S = *new State;
|
||||
|
||||
const char* envs(const char* k) {
|
||||
const char* v = getenv(k);
|
||||
@@ -624,10 +625,9 @@ void watcher() {
|
||||
void atExit() {
|
||||
if (!S.inited.load()) return;
|
||||
S.finished.store(true);
|
||||
// The watcher is detached and may still be inside a window: give it a moment to close the files.
|
||||
if (S.recording.load()) {
|
||||
for (int i = 0; i < 100 && S.recording.load(); ++i) std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
}
|
||||
// The watcher is detached and may still be inside a window: wait until it has closed the files (a 100+ MB window takes seconds
|
||||
// to flush and convert), before the process tears down.
|
||||
for (int i = 0; i < 6000 && (S.recording.load() || S.winOpen); ++i) std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
}
|
||||
|
||||
void init() {
|
||||
|
||||
Reference in New Issue
Block a user