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

Bug/skaled 1623 sigterm at exit #1695

Merged
merged 10 commits into from
Nov 21, 2023
20 changes: 14 additions & 6 deletions libdevcore/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,18 @@
}

void ExitHandler::exitHandler( int nSignalNo, ExitHandler::exit_code_t ec ) {
std::string strMessagePrefix = ExitHandler::shouldExit() ?
cc::error( "\nStop flag was already raised on. " ) +
cc::fatal( "WILL FORCE TERMINATE." ) +
cc::error( " Caught (second) signal. " ) :
cc::error( "\nCaught (first) signal. " );
std::string strMessagePrefix;
if ( nSignalNo > 0 ) {
strMessagePrefix = ( ExitHandler::shouldExit() && s_nStopSignal > 0 ) ?
cc::error( "\nStop flag was already raised on. " ) +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove color comments

cc::fatal( "WILL FORCE TERMINATE." ) +
cc::error( " Caught (second) signal. " ) :
cc::error( "\nCaught (first) signal. " );

Check warning on line 56 in libdevcore/Common.cpp

View check run for this annotation

Codecov / codecov/patch

libdevcore/Common.cpp#L50-L56

Added lines #L50 - L56 were not covered by tests
} else {
strMessagePrefix = ExitHandler::shouldExit() ?

Check warning on line 58 in libdevcore/Common.cpp

View check run for this annotation

Codecov / codecov/patch

libdevcore/Common.cpp#L58

Added line #L58 was not covered by tests
cc::error( "\nInternal exit requested while already exiting. " ) :
cc::error( "\nInternal exit initiated. " );

Check warning on line 60 in libdevcore/Common.cpp

View check run for this annotation

Codecov / codecov/patch

libdevcore/Common.cpp#L60

Added line #L60 was not covered by tests
}
std::cerr << strMessagePrefix << cc::error( skutils::signal::signal2str( nSignalNo ) )
<< "\n\n";
std::cerr.flush();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line since cerr is always flushed on line end

Expand Down Expand Up @@ -153,7 +160,8 @@

// nice exit here:

if ( ExitHandler::shouldExit() ) {
// TODO deduplicate with first if()
if ( ExitHandler::shouldExit() && s_nStopSignal > 0 && nSignalNo > 0 ) {

Check warning on line 164 in libdevcore/Common.cpp

View check run for this annotation

Codecov / codecov/patch

libdevcore/Common.cpp#L164

Added line #L164 was not covered by tests
std::cerr << ( "\n" + cc::fatal( "SIGNAL-HANDLER:" ) + " " +
cc::error( "Will force exit now..." ) + "\n\n" );
_exit( 13 );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is 13 used here ? Is there a document in which error codes are defined?

Expand Down
Loading