* Always called by ctest --wait-and-collect-instrumentation in a detached * process. Waits for the given PID to end before running the postBuild hook. * * See SpawnBuildDaemon() */
| 901 | * See SpawnBuildDaemon() |
| 902 | */ |
| 903 | int cmInstrumentation::CollectTimingAfterBuild(int ppid) |
| 904 | { |
| 905 | // Check if another process is already instrumenting the build. |
| 906 | // This lock will be released when the process exits at the end of the build. |
| 907 | if (!this->LockBuildDaemon()) { |
| 908 | return 0; |
| 909 | } |
| 910 | std::function<int()> waitForBuild = [ppid]() -> int { |
| 911 | while (0 == uv_kill(ppid, 0)) { |
| 912 | cmSystemTools::Delay(100); |
| 913 | }; |
| 914 | // FIXME(#27331): Investigate a cross-platform solution to obtain the exit |
| 915 | // code given the `ppid` above. |
| 916 | return 0; |
| 917 | }; |
| 918 | int ret = this->InstrumentCommand( |
| 919 | "build", {}, [waitForBuild]() { return waitForBuild(); }, cm::nullopt, |
| 920 | cm::nullopt, LoadQueriesAfter::Yes); |
| 921 | this->buildLock.Release(); |
| 922 | this->CollectTimingData(cmInstrumentationQuery::Hook::PostBuild); |
| 923 | return ret; |
| 924 | } |
| 925 | |
| 926 | void cmInstrumentation::AddHook(cmInstrumentationQuery::Hook hook) |
| 927 | { |