diff options
author | Matt Kneiser <matt.kneiser@mongodb.com> | 2022-07-05 17:09:20 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-07-07 18:26:31 +0000 |
commit | c44db4ac9d0c4c368835dac9f2fbd5869d885f17 (patch) | |
tree | c07de8fbd279573725d877619f263a684ec420f4 /src/mongo/db/traffic_reader_main.cpp | |
parent | 2f2dc04da0c7fd853a2ff68c245c5f6e28f50fa1 (diff) | |
download | mongo-c44db4ac9d0c4c368835dac9f2fbd5869d885f17.tar.gz |
SERVER-9434 Audit and Normalize Process Exit Codes
- Put all references to ExitCode enumerators under an enum class to namespace
all the enumerators and avoid polluting the mongo namespace with possible
naming collisions.
- Added magic-number exit codes to exit_code.h like 50 & 51
(LauncherMiddleError & LauncherError respectively).
- Reserved a range of exit codes to account for FreeBSD's usage of 64-78.
- Renamed all enums with removal of EXIT_ which could conflict or get confused
with built-in macros.
- camelCased all ExitCode enum values.
- Added the generic - ExitCode::fail - for returning 1 as failure.
- Added explicit dependency on the exit_code.h header for all files using
ExitCode's.
- Removed all references to implementation-defined exit codes like EXIT_FAILURE
and EXIT_SUCCESS.
- Narrowed return values of the shell's undocumented quit() argument to portable
values within 0-255, 0/ExitCode::clean otherwise.
- Deprecated 8 unused ExitCode's
- java
- oomMalloc
- oomRealloc
- fs
- clockSkew
- windowsServiceStop
- possibleCorruption
- test
- Wrapped the 2 Windows-only ExitCode's in #ifdef's
- ntServiceError
- windowsServiceStop
Diffstat (limited to 'src/mongo/db/traffic_reader_main.cpp')
-rw-r--r-- | src/mongo/db/traffic_reader_main.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/mongo/db/traffic_reader_main.cpp b/src/mongo/db/traffic_reader_main.cpp index 5f257cf627c..59bbf795b5f 100644 --- a/src/mongo/db/traffic_reader_main.cpp +++ b/src/mongo/db/traffic_reader_main.cpp @@ -40,6 +40,7 @@ #include "mongo/base/initializer.h" #include "mongo/db/traffic_reader.h" +#include "mongo/util/exit_code.h" #include "mongo/util/signal_handlers.h" #include "mongo/util/text.h" @@ -55,7 +56,7 @@ int main(int argc, char* argv[]) { Status status = mongo::runGlobalInitializers(std::vector<std::string>(argv, argv + argc)); if (!status.isOK()) { std::cerr << "Failed global initialization: " << status << std::endl; - return EXIT_FAILURE; + return static_cast<int>(ExitCode::fail); } startSignalProcessingThread(); @@ -86,7 +87,7 @@ int main(int argc, char* argv[]) { std::cout << "Mongo Traffic Reader Help: \n\n\t./mongotrafficreader " "-i trafficinput.txt -o mongotrafficreader_dump.bson \n\n" << desc << std::endl; - return EXIT_SUCCESS; + return static_cast<int>(ExitCode::clean); } // User can specify a --input param and it must point to a valid file @@ -95,7 +96,7 @@ int main(int argc, char* argv[]) { if (!boost::filesystem::exists(inputFile.c_str())) { std::cout << "Error: Specified file does not exist (" << inputFile.c_str() << ")" << std::endl; - return EXIT_FAILURE; + return static_cast<int>(ExitCode::fail); } // Open the connection to the input file @@ -114,7 +115,7 @@ int main(int argc, char* argv[]) { outputStream.open(outputFile, std::ios::out | std::ios::trunc | std::ios::binary); if (!outputStream.is_open()) { std::cerr << "Error writing to file: " << outputFile << std::endl; - return EXIT_FAILURE; + return static_cast<int>(ExitCode::fail); } } else { // output to std::cout @@ -124,7 +125,7 @@ int main(int argc, char* argv[]) { } } catch (const boost::program_options::error& ex) { std::cerr << ex.what() << '\n'; - return EXIT_FAILURE; + return static_cast<int>(ExitCode::fail); } mongo::trafficRecordingFileToMongoReplayFile(inputFd, outputStream); |