Skip to content

Commit

Permalink
Support SIGABRT to generate coredump.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed May 25, 2022
1 parent 1d503c7 commit 0304e78
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions trunk/src/app/srs_app_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ srs_error_t SrsSignalManager::start()
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sigaction(SRS_SIGNAL_GRACEFULLY_QUIT, &sa, NULL);

sa.sa_handler = SrsSignalManager::sig_catcher;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sigaction(SRS_SIGNAL_ASSERT_ABORT, &sa, NULL);

sa.sa_handler = SrsSignalManager::sig_catcher;
sigemptyset(&sa.sa_mask);
Expand Down Expand Up @@ -971,6 +976,13 @@ srs_error_t SrsServer::cycle()

void SrsServer::on_signal(int signo)
{
// For signal to quit with coredump.
if (signo == SRS_SIGNAL_ASSERT_ABORT) {
srs_trace("abort with coredump, signo=%d", signo);
srs_assert(false);
return;
}

if (signo == SRS_SIGNAL_RELOAD) {
srs_trace("reload config, signo=%d", signo);
signal_reload = true;
Expand Down
2 changes: 2 additions & 0 deletions trunk/src/kernel/srs_kernel_consts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@
// The signal for srs to gracefully quit, do carefully dispose then exit.
// @see https://github.com/ossrs/srs/issues/1579
#define SRS_SIGNAL_GRACEFULLY_QUIT SIGQUIT
// The signal for SRS to abort by assert(false).
#define SRS_SIGNAL_ASSERT_ABORT SIGABRT

// The application level signals.
// Persistence the config in memory to config file.
Expand Down

0 comments on commit 0304e78

Please sign in to comment.