Repository navigation
Handle EINTR exit codes from select - #516
Merged
Merged
Conversation
This fixes MisterTea#503, where etserver crashed if select returned an EINTR error code. This is apparently normal behavior, and the caller is expected to retry when this occurs. For codepaths that `FATAL_FAIL` on the select results, add special handling to retry instead of crashing. Note that the specific approach varies for each callsite. Doing this impacts SIGINT, however, so to keep Ctrl-C working to exit the process fix, update the Sentry SIGINT handler so that it calls `et::InterruptSignalHandler`, enabling the process to exit semi-gracefully (however it still prints a callstack). # Testing To test, first call `etterminal` and do not provide any input: ``` $ ./etterminal Call etterminal with --idpasskey or --idpasskeyfile, or feed this information on stdin ``` Then launch `etserver` and verify it exits with Ctrl-C (or equivalent) ``` $ ./etserver --logtostdout -v 9 [INFO 2022-04-30 19:46:54,927 etserver-main TerminalServerMain.cpp:185] In child, about to start server. [INFO 2022-04-30 19:46:54,928 etserver-main TcpSocketHandler.cpp:224] Listening on 0.0.0.0:2022/2/1/6 [INFO 2022-04-30 19:46:54,928 etserver-main TcpSocketHandler.cpp:224] Listening on 0.0.0.0:2022/10/1/6 [INFO 2022-04-30 19:46:54,928 etserver-main TerminalServer.cpp:23] Creating server ^CShutting down sentry [ERROR 2022-04-30 19:46:57,863 etserver-main Headers.hpp:411] Stack Trace: [0] 0x1b788f el::base::Writer& el::base::Writer::operator<< <ust::StackTrace>(ust::StackTrace const&) (easylogging++.h:3215) [1] 0x1d05a3 et::TelemetryService::TelemetryService(bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)::{lambda(int)MisterTea#2}::_FUN(int) (TelemetryService.cpp:190) [2] 0x7f019558a210 [3] 0x7f019565c12b __select [4] 0x1be4bf et::TerminalServer::run() (TerminalServer.cpp:63) [5] 0x175a9f main (TerminalServerMain.cpp:195) [6] 0x7f019556b0b3 __libc_start_main [7] 0x17840e _start Got interrupt Got interrupt (perhaps ctrl+c?). Exiting. Shutting down sentry ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes #503, where etserver crashed if select returned an EINTR error code. This is apparently normal behavior, and the caller is expected to retry when this occurs.
For codepaths that
FATAL_FAILon the select results, add special handling to retry instead of crashing. Note that the specific approach varies for each callsite.Doing this impacts SIGINT, however, so to keep Ctrl-C working to exit the process fix, update the Sentry SIGINT handler so that it calls
et::InterruptSignalHandler, enabling the process to exit semi-gracefully (however it still prints a callstack).Testing
To test, first call
etterminaland do not provide any input:Then launch
etserverand verify it exits with Ctrl-C (or equivalent)