Skip to content

Commit

Permalink
#783: Shutdown asprof gracefully on SIGTERM
Browse files Browse the repository at this point in the history
  • Loading branch information
apangin committed Dec 3, 2023
1 parent 3d28531 commit db9c4c4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/launcher/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ int main(int argc, const char** argv) {
fprintf(stderr, "Profiling for %d seconds\n", duration);
end_time = time_micros() + duration * 1000000ULL;
signal(SIGINT, sigint_handler);
signal(SIGTERM, sigint_handler);

while (time_micros() < end_time) {
if (kill(pid, 0) != 0) {
Expand All @@ -526,8 +527,9 @@ int main(int argc, const char** argv) {
sleep(1);
}

fprintf(stderr, end_time != 0 ? "Done\n" : "Interrupted\n");
signal(SIGINT, SIG_DFL);
fprintf(stderr, "Done\n");
// Do not reset SIGTERM handler to allow graceful shutdown

run_jattach(pid, String("stop,file=") << file << "," << output << format << ",log=" << logfile);
} else {
Expand Down

0 comments on commit db9c4c4

Please sign in to comment.