Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call functions registered with atexit on SIGTERM #261

Merged
merged 1 commit into from
May 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/conmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ int main(int argc, char *argv[])

/* ignoring SIGPIPE prevents conmon from being spuriously killed */
signal(SIGPIPE, SIG_IGN);
/* Catch SIGTERM and call exit(). This causes the atexit functions to be called. */
signal(SIGTERM, handle_signal);

int start_pipe_fd = get_pipe_fd_from_env("_OCI_STARTPIPE");
if (start_pipe_fd > 0) {
Expand Down
5 changes: 5 additions & 0 deletions src/ctr_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,8 @@ void reap_children()
while (waitpid(-1, NULL, WNOHANG) > 0)
;
}

void handle_signal(G_GNUC_UNUSED const int signum)
{
exit(EXIT_FAILURE);
}
1 change: 1 addition & 0 deletions src/ctr_exit.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ void runtime_exit_cb(G_GNUC_UNUSED GPid pid, int status, G_GNUC_UNUSED gpointer
void container_exit_cb(G_GNUC_UNUSED GPid pid, int status, G_GNUC_UNUSED gpointer user_data);
void do_exit_command();
void reap_children();
void handle_signal(G_GNUC_UNUSED const int signum);

#endif // CTR_EXIT_H