Skip to content

Commit

Permalink
Merge pull request #11601 from filimonov/fix_client_exit_code
Browse files Browse the repository at this point in the history
Fix corner case (only) for exit code overflow
  • Loading branch information
alexey-milovidov committed Jun 11, 2020
2 parents 89df991 + e690d0a commit d5c2008
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion programs/client/Client.cpp
Expand Up @@ -1920,7 +1920,11 @@ class Client : public Poco::Util::Application
std::string text = e.displayText();
std::cerr << "Code: " << e.code() << ". " << text << std::endl;
std::cerr << "Table №" << i << std::endl << std::endl;
exit(e.code());
/// Avoid the case when error exit code can possibly overflow to normal (zero).
auto exit_code = e.code() % 256;
if (exit_code == 0)
exit_code = 255;
exit(exit_code);
}
}

Expand Down

0 comments on commit d5c2008

Please sign in to comment.