Skip to content

Commit

Permalink
diverse exit codes (#482)
Browse files Browse the repository at this point in the history
* Enhance exit-codes

* follow alphabetical order

* leftover exits

* Revert "leftover exits"

This reverts commit 91bc203.
  • Loading branch information
J-A-U committed Apr 20, 2022
1 parent 434073d commit bb4bd1f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/vzlogger.cpp
Expand Up @@ -35,6 +35,7 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sysexits.h>
#include <time.h>
#include <unistd.h>

Expand Down Expand Up @@ -111,7 +112,7 @@ void openLogfile(bool skip_lock = false) {
if (logfd == NULL) {
print(log_alert, "opening logfile \"%s\" failed: %s", (char *)0, options.log().c_str(),
strerror(errno));
exit(EXIT_FAILURE);
exit(EX_CANTCREAT);
}

if (!skip_lock)
Expand Down Expand Up @@ -256,7 +257,7 @@ void daemonize() {

int i = fork();
if (i < 0) {
exit(EXIT_FAILURE); /* fork error */
exit(EX_OSERR); /* fork error */
} else if (i > 0) {
exit(EXIT_SUCCESS); /* parent exits */
}
Expand Down Expand Up @@ -446,7 +447,7 @@ int main(int argc, char *argv[]) {
/* parse command line and file options */
// TODO command line should have a higher priority as file
if (config_parse_cli(argc, argv, &options) != SUCCESS) {
return EXIT_FAILURE;
return EX_USAGE;
}

// always (that's why log_alert is used) print version info to log file:
Expand All @@ -460,7 +461,7 @@ int main(int argc, char *argv[]) {
std::stringstream oss;
oss << e.what();
print(log_alert, "Failed to parse configuration due to: %s", NULL, oss.str().c_str());
return EXIT_FAILURE;
return EX_CONFIG;
}

// make sure command line options override config settings, just re-parse
Expand Down

0 comments on commit bb4bd1f

Please sign in to comment.