From b841c268ae2d7572bc2caf21263692737cfe5648 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Thu, 17 Mar 2016 11:55:23 +0100 Subject: [PATCH] main: use valid exit value MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: Id49850dbb1152f4b6cbdbafc42268974e5071897 Signed-off-by: José Bollo --- src/main.c | 30 +++++++++++++++--------------- src/rest-api.c | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main.c b/src/main.c index af90eaec..da5984ec 100644 --- a/src/main.c +++ b/src/main.c @@ -294,7 +294,7 @@ int main(int argc, char *argv[]) { // if no argument print help and return if (argc < 2) { printHelp(programName); - return (-1); + return 1; } // build GNU getopt info from cliOptions @@ -471,7 +471,7 @@ int main(int argc, char *argv[]) { // ------------------ sanity check ---------------------------------------- if ((session->background) && (session->foreground)) { fprintf (stderr, "%s ERR: cannot select foreground & background at the same time\n",configTime()); - exit (-1); + exit (1); } // ------------------ Some useful default values ------------------------- @@ -508,7 +508,7 @@ int main(int argc, char *argv[]) { // ------------------ clean exit on CTR-C signal ------------------------ if (signal (SIGINT, signalQuit) == SIG_ERR) { fprintf (stderr, "%s Quit Signal received.",configTime()); - return (-1); + return 1; } // save exitPoint context when returning from longjmp closeSession and exit @@ -624,57 +624,57 @@ normalExit: // ------------- Fatal ERROR display error and quit ------------- errorSetuid: fprintf (stderr,"\nERR:AFB-daemon Failed to change UID to username=[%s]\n\n", session->config->setuid); - exit (-1); + exit (1); //errorNoRoot: // fprintf (stderr,"\nERR:AFB-daemon Not allow to run as root [use --seteuid=username option]\n\n"); -// exit (-1); +// exit (1); errorPidFile: fprintf (stderr,"\nERR:AFB-daemon Failed to write pid file [%s]\n\n", session->config->pidfile); - exit (-1); + exit (1); errorFork: fprintf (stderr,"\nERR:AFB-daemon Failed to fork son process\n\n"); - exit (-1); + exit (1); needValueForOption: fprintf (stderr,"\nERR:AFB-daemon option [--%s] need a value i.e. --%s=xxx\n\n" ,gnuOptions[optionIndex].name, gnuOptions[optionIndex].name); - exit (-1); + exit (1); noValueForOption: fprintf (stderr,"\nERR:AFB-daemon option [--%s] don't take value\n\n" ,gnuOptions[optionIndex].name); - exit (-1); + exit (1); notAnInteger: fprintf (stderr,"\nERR:AFB-daemon option [--%s] requirer an interger i.e. --%s=9\n\n" ,gnuOptions[optionIndex].name, gnuOptions[optionIndex].name); - exit (-1); + exit (1); badMode: fprintf (stderr,"\nERR:AFB-daemon option [--%s] only accepts local, global or remote.\n\n" ,gnuOptions[optionIndex].name); - exit (-1); + exit (1); exitOnSignal: fprintf (stderr,"\n%s INF:AFB-daemon pid=%d received exit signal (Hopefully crtl-C or --kill-previous !!!)\n\n" ,configTime(), getpid()); - exit (-1); + exit (1); errConsole: fprintf (stderr,"\nERR:AFB-daemon cannot open /dev/console (use --foreground)\n\n"); - exit (-1); + exit (1); errSessiondir: fprintf (stderr,"\nERR:AFB-daemon cannot read/write session dir\n\n"); - exit (-1); + exit (1); exitInitLoop: // try to unlink pid file if any if (session->background && session->config->pidfile != NULL) unlink (session->config->pidfile); - exit (-1); + exit (1); } /* END AFB-daemon() */ diff --git a/src/rest-api.c b/src/rest-api.c index 0fa27693..643acb57 100644 --- a/src/rest-api.c +++ b/src/rest-api.c @@ -657,7 +657,7 @@ void initPlugins(AFB_session *session) { if (count == 0) { fprintf(stderr, "No plugins found, afb-daemon is unlikely to work in this configuration, exiting...\n"); - exit (-1); + exit (1); } // downsize structure to effective number of loaded plugins -- 2.16.6