summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne H Juul <arnej27959@users.noreply.github.com>2020-07-05 19:26:45 +0200
committerGitHub <noreply@github.com>2020-07-05 19:26:45 +0200
commitccb744120b068290c685cf418ff0c254b54dcb39 (patch)
tree31b71b015130ce0835089886e2d9d0a53a5509f4
parent9b7a9a8b1dbc828e632cf9f812db271c4a132320 (diff)
parentc55327290e5d894333f2d2002e1a778bc5b7ba2e (diff)
Merge pull request #13796 from vespa-engine/arnej/less-exit-calls-2
Arnej/less exit calls 2
-rw-r--r--configd/src/apps/sentinel/sentinel.cpp16
-rw-r--r--configd/src/apps/sentinel/service.cpp7
-rw-r--r--configd/src/apps/su/main.cpp12
-rw-r--r--configutil/src/apps/configstatus/main.cpp7
-rw-r--r--configutil/src/apps/modelinspect/main.cpp7
-rw-r--r--configutil/src/lib/configstatus.cpp3
-rw-r--r--configutil/src/lib/modelinspect.cpp3
-rw-r--r--fastlib/src/vespa/fastlib/text/apps/extcase.cpp2
-rw-r--r--fastos/src/vespa/fastos/file.cpp7
-rw-r--r--fastos/src/vespa/fastos/unix_ipc.cpp9
-rw-r--r--fastos/src/vespa/fastos/unix_process.cpp9
-rw-r--r--fbench/src/fbench/fbench.cpp3
-rw-r--r--fsa/queryproc/count_plain_grams.cpp2
-rw-r--r--fsa/queryproc/count_sorted_grams.cpp2
-rw-r--r--fsa/queryproc/p2s_ratio.cpp2
-rw-r--r--fsa/src/alltest/conceptnet_test.cpp13
-rw-r--r--fsa/src/alltest/fsamanager_test.cpp2
-rw-r--r--fsa/src/alltest/lookup_test.cpp2
-rw-r--r--fsa/src/apps/fsadump/fsadump.cpp10
-rw-r--r--fsa/src/apps/fsainfo/fsainfo.cpp8
-rw-r--r--fsa/src/apps/makefsa/makefsa.cpp10
-rw-r--r--logd/src/tests/rotate/dummyserver.cpp3
-rw-r--r--logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp7
-rw-r--r--logforwarder/src/apps/vespa-logforwarder-start/child-handler.cpp3
-rw-r--r--logforwarder/src/apps/vespa-logforwarder-start/main.cpp2
-rw-r--r--searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp9
-rw-r--r--searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp57
-rw-r--r--searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp2
-rw-r--r--searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp6
-rw-r--r--searchsummary/src/tests/extractkeywords/extractkeywordstest.h2
-rw-r--r--staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp3
-rw-r--r--storage/src/vespa/storage/tools/generatedistributionbits.cpp2
-rw-r--r--storageapi/src/vespa/storageapi/app/getbucketid.cpp2
-rw-r--r--storageserver/src/apps/storaged/storage.cpp5
-rw-r--r--vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp3
-rw-r--r--vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp11
-rw-r--r--vespalog/src/logctl/logctl.cpp16
-rw-r--r--vespalog/src/logger/logger.cpp2
-rw-r--r--vespalog/src/logger/logreplay.c4
-rw-r--r--vespalog/src/logger/runserver.cpp37
-rw-r--r--vespalog/src/test/bufferedlogskiptest.cpp8
-rw-r--r--vespalog/src/test/bufferedlogtest.cpp21
-rw-r--r--vespalog/src/test/logtest.cpp2
-rw-r--r--vespalog/src/test/rejectfiltertest.cpp7
-rw-r--r--vespalog/src/test/simple/logtest.cpp2
-rw-r--r--vespalog/src/test/threads/testthreads.cpp7
-rw-r--r--vespalog/src/vespa-logfmt/logfilter.c13
47 files changed, 188 insertions, 184 deletions
diff --git a/configd/src/apps/sentinel/sentinel.cpp b/configd/src/apps/sentinel/sentinel.cpp
index 9f179e96393..1bab29e727e 100644
--- a/configd/src/apps/sentinel/sentinel.cpp
+++ b/configd/src/apps/sentinel/sentinel.cpp
@@ -30,7 +30,7 @@ main(int argc, char **argv)
if (c != 'c') {
LOG(error, "Usage: %s -c <config-id>", argv[0]);
EV_STOPPING("config-sentinel", "Bad arguments on command line");
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
std::string configId(optarg);
@@ -45,7 +45,7 @@ main(int argc, char **argv)
if (chdir(rootDir) == -1) {
LOG(error, "Fatal: Cannot cd to $ROOT (%s)", rootDir);
EV_STOPPING("config-sentinel", "Cannot cd to $ROOT");
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
EV_STARTED("config-sentinel");
@@ -57,7 +57,7 @@ main(int argc, char **argv)
if (setenv("LC_ALL", "C", 1) != 0) {
LOG(error, "Unable to set locale");
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
setlocale(LC_ALL, "C");
@@ -69,15 +69,15 @@ main(int argc, char **argv)
} catch (ConfigTimeoutException & ex) {
LOG(warning, "Timeout getting config, please check your setup. Will exit and restart: %s", ex.getMessage().c_str());
EV_STOPPING("config-sentinel", ex.what());
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
} catch (InvalidConfigException& ex) {
LOG(error, "Fatal: Invalid configuration, please check your setup: %s", ex.getMessage().c_str());
EV_STOPPING("config-sentinel", ex.what());
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
} catch (ConfigRuntimeException& ex) {
LOG(error, "Fatal: Could not get config, please check your setup: %s", ex.getMessage().c_str());
EV_STOPPING("config-sentinel", ex.what());
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
struct timeval lastTv;
@@ -91,11 +91,11 @@ main(int argc, char **argv)
} catch (vespalib::PortListenException& ex) {
LOG(error, "Fatal: %s", ex.getMessage().c_str());
EV_STOPPING("config-sentinel", ex.what());
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
} catch (vespalib::FatalException& ex) {
LOG(error, "Fatal: %s", ex.getMessage().c_str());
EV_STOPPING("config-sentinel", ex.what());
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
if (vespalib::SignalHandler::CHLD.check()) {
continue;
diff --git a/configd/src/apps/sentinel/service.cpp b/configd/src/apps/sentinel/service.cpp
index a502ce50f71..ed25cac2eee 100644
--- a/configd/src/apps/sentinel/service.cpp
+++ b/configd/src/apps/sentinel/service.cpp
@@ -6,6 +6,7 @@
#include <vespa/vespalib/util/signalhandler.h>
#include <csignal>
+#include <cstdlib>
#include <unistd.h>
#include <fcntl.h>
#include <sys/wait.h>
@@ -215,7 +216,7 @@ Service::start()
}
EV_STARTING(name().c_str());
runChild(pipes); // This function should not return.
- _exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
}
close(pipes[1]); // close writing end
@@ -373,7 +374,7 @@ Service::runChild(int pipes[2])
snprintf(buf, sizeof buf, "open /dev/null for fd 0: got %d "
"(%s)", fd, strerror(errno));
[[maybe_unused]] auto writeRes = write(pipes[1], buf, strlen(buf));
- _exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
}
fcntl(0, F_SETFD, 0); // Don't close on exec
@@ -383,7 +384,7 @@ Service::runChild(int pipes[2])
snprintf(buf, sizeof buf, "exec error: %s for /bin/sh -c '%s'",
strerror(errno), _config->command.c_str());
[[maybe_unused]] auto writeRes = write(pipes[1], buf, strlen(buf));
- _exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
}
const vespalib::string &
diff --git a/configd/src/apps/su/main.cpp b/configd/src/apps/su/main.cpp
index abef5c69036..095bbdb6844 100644
--- a/configd/src/apps/su/main.cpp
+++ b/configd/src/apps/su/main.cpp
@@ -14,7 +14,7 @@ int main(int argc, char** argv)
{
if (argc < 2) {
fprintf(stderr, "missing arguments, usage: vespa-run-as-vespa-user <cmd> [args ...]\n");
- exit(1);
+ return 1;
}
const char *username = getenv("VESPA_USER");
if (username == nullptr) {
@@ -23,7 +23,7 @@ int main(int argc, char** argv)
struct passwd *p = getpwnam(username);
if (p == nullptr) {
fprintf(stderr, "FATAL error: user '%s' missing in passwd file\n", username);
- exit(1);
+ return 1;
}
gid_t g = p->pw_gid;
uid_t u = p->pw_uid;
@@ -33,19 +33,19 @@ int main(int argc, char** argv)
if (g != oldg && setgid(g) != 0) {
perror("FATAL error: could not change group id");
- exit(1);
+ return 1;
}
size_t listsize = 1;
gid_t grouplist[1] = { g };
if ((g != oldg || u != oldu) && setgroups(listsize, grouplist) != 0) {
perror("FATAL error: could not setgroups");
- exit(1);
+ return 1;
}
if (u != oldu && setuid(u) != 0) {
perror("FATAL error: could not change user id");
- exit(1);
+ return 1;
}
execvp(argv[1], &argv[1]);
perror("FATAL error: execvp failed");
- exit(1);
+ return 1;
}
diff --git a/configutil/src/apps/configstatus/main.cpp b/configutil/src/apps/configstatus/main.cpp
index d1159a5e33c..befd0e649f6 100644
--- a/configutil/src/apps/configstatus/main.cpp
+++ b/configutil/src/apps/configstatus/main.cpp
@@ -3,7 +3,8 @@
#include <vespa/defaults.h>
#include <vespa/vespalib/text/stringtokenizer.h>
#include <iostream>
-#include <lib/configstatus.h>
+#include <cstdlib>
+#include "lib/configstatus.h"
#include <vespa/fastos/app.h>
#include <vespa/log/log.h>
@@ -48,13 +49,13 @@ int Application::parseOpts() {
break;
case 'h':
usage();
- exit(0);
+ std::_Exit(0);
case 'f':
_flags.host_filter = parse_host_set(optArg);
break;
default:
usage();
- exit(1);
+ std::_Exit(1);
}
}
if (_specString.empty()) {
diff --git a/configutil/src/apps/modelinspect/main.cpp b/configutil/src/apps/modelinspect/main.cpp
index 0404cf0ae86..c43294be8de 100644
--- a/configutil/src/apps/modelinspect/main.cpp
+++ b/configutil/src/apps/modelinspect/main.cpp
@@ -2,7 +2,8 @@
#include <vespa/defaults.h>
#include <iostream>
-#include <lib/modelinspect.h>
+#include <cstdlib>
+#include "lib/modelinspect.h"
#include <vespa/vespalib/text/stringtokenizer.h>
#include <vespa/fastos/app.h>
@@ -56,7 +57,7 @@ Application::parseOpts()
return _argc;
default:
usage();
- exit(1);
+ std::_Exit(1);
}
}
if (_specString.empty()) {
@@ -84,7 +85,7 @@ Application::getConfigUri()
}
catch (std::exception &e) {
std::cerr << "FATAL ERROR: failed to set up model configuration: " << e.what() << "\n";
- exit(1);
+ std::_Exit(1);
}
}
diff --git a/configutil/src/lib/configstatus.cpp b/configutil/src/lib/configstatus.cpp
index 1831a39b18a..415edf6defc 100644
--- a/configutil/src/lib/configstatus.cpp
+++ b/configutil/src/lib/configstatus.cpp
@@ -9,6 +9,7 @@
#include <vbench/http/http_client.h>
#include <vespa/config/common/exceptions.h>
#include <iostream>
+#include <cstdlib>
using configdefinitions::tagsContain;
@@ -129,7 +130,7 @@ ConfigStatus::ConfigStatus(Flags flags, const config::ConfigUri uri)
if (_cfg.get() == NULL) {
std::cerr << "FATAL ERROR: failed to get model configuration." << std::endl;
- exit(1);
+ std::_Exit(1);
}
}
diff --git a/configutil/src/lib/modelinspect.cpp b/configutil/src/lib/modelinspect.cpp
index bf0536a9d4c..db5709cc95b 100644
--- a/configutil/src/lib/modelinspect.cpp
+++ b/configutil/src/lib/modelinspect.cpp
@@ -6,6 +6,7 @@
#include <vespa/config/common/exceptions.h>
#include <iostream>
#include <algorithm>
+#include <cstdlib>
using configdefinitions::tagsContain;
using configdefinitions::upcase;
@@ -35,7 +36,7 @@ ModelInspect::ModelInspect(Flags flags, const config::ConfigUri uri, std::ostrea
if (_flags.verbose) std::cerr << "success!\n";
} else {
std::cerr << "FATAL ERROR: failed to get model configuration.\n";
- exit(1);
+ std::_Exit(1);
}
}
diff --git a/fastlib/src/vespa/fastlib/text/apps/extcase.cpp b/fastlib/src/vespa/fastlib/text/apps/extcase.cpp
index b713523af08..63ec841f84c 100644
--- a/fastlib/src/vespa/fastlib/text/apps/extcase.cpp
+++ b/fastlib/src/vespa/fastlib/text/apps/extcase.cpp
@@ -166,7 +166,5 @@ main(int argc, char **argv)
file.Close();
DumpCase();
-
- exit(0);
return 0;
}
diff --git a/fastos/src/vespa/fastos/file.cpp b/fastos/src/vespa/fastos/file.cpp
index 861dd9f4259..cacdf4da836 100644
--- a/fastos/src/vespa/fastos/file.cpp
+++ b/fastos/src/vespa/fastos/file.cpp
@@ -10,6 +10,7 @@
#include <sstream>
#include <cstring>
#include <fcntl.h>
+#include <cstdlib>
DirectIOException::DirectIOException(const char * fileName, const void * buffer, size_t length, int64_t offset) :
std::exception(),
@@ -339,19 +340,19 @@ FastOS_FileInterface::MakeDirIfNotPresentOrExit(const char *name)
return;
fprintf(stderr, "%s is not a directory\n", name);
- exit(1);
+ std::_Exit(1);
}
if (statInfo._error != FastOS_StatInfo::FileNotFound) {
std::error_code ec(errno, std::system_category());
fprintf(stderr, "Could not stat %s: %s\n", name, ec.message().c_str());
- exit(1);
+ std::_Exit(1);
}
if (!FastOS_File::MakeDirectory(name)) {
std::error_code ec(errno, std::system_category());
fprintf(stderr, "Could not mkdir(\"%s\", 0775): %s\n", name, ec.message().c_str());
- exit(1);
+ std::_Exit(1);
}
}
diff --git a/fastos/src/vespa/fastos/unix_ipc.cpp b/fastos/src/vespa/fastos/unix_ipc.cpp
index 4c8e3102dbb..09f8e6162f7 100644
--- a/fastos/src/vespa/fastos/unix_ipc.cpp
+++ b/fastos/src/vespa/fastos/unix_ipc.cpp
@@ -3,6 +3,7 @@
#include "ringbuffer.h"
#include <cassert>
#include <cstring>
+#include <cstdlib>
#include <unistd.h>
#include <fcntl.h>
#include <memory>
@@ -21,7 +22,7 @@ FastOS_UNIX_IPCHelper (FastOS_ApplicationInterface *app, int descriptor)
if(pipe(_wakeupPipe) != 0) {
perror("pipe wakeuppipe");
- exit(1);
+ std::_Exit(1);
} else {
SetBlocking(_wakeupPipe[0], false);
SetBlocking(_wakeupPipe[1], true);
@@ -536,10 +537,10 @@ Run(FastOS_ThreadInterface *thisThread, void *arg)
if ((fds[i].events & POLLOUT) != 0)
printf("Write %d\n", fds[i].fd);
}
- exit(1);
- }
- else
+ std::_Exit(1);
+ } else {
break;
+ }
}
bool woken = false;
diff --git a/fastos/src/vespa/fastos/unix_process.cpp b/fastos/src/vespa/fastos/unix_process.cpp
index 087f800e668..b66d5ce8346 100644
--- a/fastos/src/vespa/fastos/unix_process.cpp
+++ b/fastos/src/vespa/fastos/unix_process.cpp
@@ -4,6 +4,7 @@
#include "ringbuffer.h"
#include <vector>
#include <cstring>
+#include <cstdlib>
#include <unistd.h>
#include <fcntl.h>
#include <sys/socket.h>
@@ -947,12 +948,12 @@ ReadBytes(int fd, void *buffer, int bytes)
if (bytesRead < 0) {
//perror("FATAL: FastOS_UNIX_ProcessStarter read");
- exit(1);
+ std::_Exit(1);
}
else if(bytesRead == 0)
{
//fprintf(stderr, "FATAL: FastOS_UNIX_RealProcessStart read 0\n");
- exit(1);
+ std::_Exit(1);
}
writePtr += bytesRead;
@@ -977,12 +978,12 @@ WriteBytes(int fd, const void *buffer, int bytes, bool ignoreFailure)
if (ignoreFailure)
return;
//perror("FATAL: FastOS_UNIX_ProcessStarter write");
- exit(1);
+ std::_Exit(1);
} else if (bytesWritten == 0) {
if (ignoreFailure)
return;
//fprintf(stderr, "FATAL: FastOS_UNIX_RealProcessStart write 0\n");
- exit(1);
+ std::_Exit(1);
}
readPtr += bytesWritten;
diff --git a/fbench/src/fbench/fbench.cpp b/fbench/src/fbench/fbench.cpp
index 88d27a33bd7..efac34409cc 100644
--- a/fbench/src/fbench/fbench.cpp
+++ b/fbench/src/fbench/fbench.cpp
@@ -14,6 +14,7 @@
#include <cmath>
#include <csignal>
#include <cinttypes>
+#include <cstdlib>
namespace {
@@ -327,7 +328,7 @@ FBench::Exit()
StopClients();
printf("\n");
PrintSummary();
- exit(0);
+ std::_Exit(0);
}
int
diff --git a/fsa/queryproc/count_plain_grams.cpp b/fsa/queryproc/count_plain_grams.cpp
index ef400db9bc4..ffb5c730cdc 100644
--- a/fsa/queryproc/count_plain_grams.cpp
+++ b/fsa/queryproc/count_plain_grams.cpp
@@ -43,7 +43,7 @@ int main(int argc, char **argv)
if(argc!=2){
std::cerr << "usage: " << argv[0] << " fsa_file" << std::endl;
- exit(1);
+ return 1;
}
FSA fsa(argv[1]);
diff --git a/fsa/queryproc/count_sorted_grams.cpp b/fsa/queryproc/count_sorted_grams.cpp
index cd047633e72..84350068f69 100644
--- a/fsa/queryproc/count_sorted_grams.cpp
+++ b/fsa/queryproc/count_sorted_grams.cpp
@@ -28,7 +28,7 @@ int main(int argc, char **argv)
if(argc!=2){
std::cerr << "usage: " << argv[0] << " sorted_fsa_file" << std::endl;
- exit(1);
+ return 1;
}
FSA fsa(argv[1]);
diff --git a/fsa/queryproc/p2s_ratio.cpp b/fsa/queryproc/p2s_ratio.cpp
index 830985813a8..9238df6eddc 100644
--- a/fsa/queryproc/p2s_ratio.cpp
+++ b/fsa/queryproc/p2s_ratio.cpp
@@ -24,7 +24,7 @@ int main(int argc, char **argv)
if(argc!=3){
std::cerr << "usage: " << argv[0] << " plain_count_fsa_file sorted_count_fsa_file" << std::endl;
- exit(1);
+ return 1;
}
FSA plain_fsa(argv[1]);
diff --git a/fsa/src/alltest/conceptnet_test.cpp b/fsa/src/alltest/conceptnet_test.cpp
index 157903fcd4e..03a88434776 100644
--- a/fsa/src/alltest/conceptnet_test.cpp
+++ b/fsa/src/alltest/conceptnet_test.cpp
@@ -29,13 +29,13 @@ int main(int argc, char **argv)
break;
case '?':
fprintf(stderr,"conceptnet_test: unrecognized option");
- exit(1);
+ return 1;
}
}
if(optind>=argc){
fprintf(stderr,"usage: conceptnet_test [-aec] DOMAIN [UNIT ...]\n");
- exit(1);
+ return 1;
}
std::string domain = argv[optind];
@@ -44,7 +44,7 @@ int main(int argc, char **argv)
domain + ".fsa",
domain + ".dat")){
fprintf(stderr,"failed to load concept net %s\n",domain.c_str());
- exit(1);
+ return 1;
}
ConceptNet::Handle* cn = ConceptNetManager::instance().get(domain);
@@ -71,10 +71,9 @@ int main(int argc, char **argv)
}
}
}
- }
- else {
+ } else {
fprintf(stderr,"failed to load concept net %s\n",domain.c_str());
- exit(1);
+ return 1;
}
-
+ return 0;
}
diff --git a/fsa/src/alltest/fsamanager_test.cpp b/fsa/src/alltest/fsamanager_test.cpp
index aee97432347..a4d8b234415 100644
--- a/fsa/src/alltest/fsamanager_test.cpp
+++ b/fsa/src/alltest/fsamanager_test.cpp
@@ -12,7 +12,7 @@ int main(int argc, char** argv)
{
if(argc<3){
std::cerr << "usage: fsamanager_test cache_dir fsa_file_or_url [fsa_file_or_url ...]\n";
- exit(1);
+ return 1;
}
FSAManager::instance().setCacheDir(argv[1]);
diff --git a/fsa/src/alltest/lookup_test.cpp b/fsa/src/alltest/lookup_test.cpp
index dcb570f09a2..dcc20075a98 100644
--- a/fsa/src/alltest/lookup_test.cpp
+++ b/fsa/src/alltest/lookup_test.cpp
@@ -20,7 +20,7 @@ int main(int argc, char** argv)
if(argc!=2){
std::cerr << "usage: lookup_test fsafile <input >output" << std::endl;
- exit(1);
+ return 1;
}
FSA f(argv[1]);
diff --git a/fsa/src/apps/fsadump/fsadump.cpp b/fsa/src/apps/fsadump/fsadump.cpp
index 16e128f33ca..5308f113356 100644
--- a/fsa/src/apps/fsadump/fsadump.cpp
+++ b/fsa/src/apps/fsadump/fsadump.cpp
@@ -80,10 +80,10 @@ int main(int argc, char** argv)
break;
case 'h':
usage(argv[0]);
- exit(0);
+ return 0;
case 'V':
version();
- exit(0);
+ return 0;
case 't':
format = OUTPUT_TEXT;
break;
@@ -101,13 +101,13 @@ int main(int argc, char** argv)
break;
case '?':
usage(argv[0],"unrecognized option");
- exit(1);
+ return 1;
}
}
if(optind!=argc-1){
usage(argv[0],"required parameter(s) missing");
- exit(1);
+ return 1;
}
if(format==OUTPUT_UNDEF) // use default format (warning?)
@@ -119,7 +119,7 @@ int main(int argc, char** argv)
if(!fsa.isOk()){
std::cerr << "Failed to open fsa file (" << input_file << ")" << std::endl;
- exit(1);
+ return 1;
}
std::string meta,temp;
diff --git a/fsa/src/apps/fsainfo/fsainfo.cpp b/fsa/src/apps/fsainfo/fsainfo.cpp
index 31b23c17401..61af267545b 100644
--- a/fsa/src/apps/fsainfo/fsainfo.cpp
+++ b/fsa/src/apps/fsainfo/fsainfo.cpp
@@ -48,19 +48,19 @@ int main(int argc, char** argv)
switch(opt){
case 'h':
usage(argv[0]);
- exit(0);
+ return 0;
case 'V':
version();
- exit(0);
+ return 0;
case '?':
usage(argv[0],"unrecognized option");
- exit(1);
+ return 1;
}
}
if(optind!=argc-1){
usage(argv[0],"required parameter fsa is missing");
- exit(1);
+ return 1;
}
fsa_file = argv[optind];
diff --git a/fsa/src/apps/makefsa/makefsa.cpp b/fsa/src/apps/makefsa/makefsa.cpp
index 59b7e2c27d0..f86a0d781c1 100644
--- a/fsa/src/apps/makefsa/makefsa.cpp
+++ b/fsa/src/apps/makefsa/makefsa.cpp
@@ -87,10 +87,10 @@ int main(int argc, char** argv)
break;
case 'h':
usage(argv[0]);
- exit(0);
+ return 0;
case 'V':
version();
- exit(0);
+ return 0;
case 't':
format = INPUT_TEXT;
break;
@@ -101,7 +101,7 @@ int main(int argc, char** argv)
num_size = strtoul(optarg,NULL,0);
if(num_size!=1 && num_size!=2 && num_size!=4){
usage(argv[0],"invalid numerical info size (-s)");
- exit(1);
+ return 1;
}
break;
case 'z':
@@ -124,7 +124,7 @@ int main(int argc, char** argv)
break;
case '?':
usage(argv[0],"unrecognized option");
- exit(1);
+ return 1;
}
}
@@ -141,7 +141,7 @@ int main(int argc, char** argv)
}
else{
usage(argv[0],"required parameter(s) missing");
- exit(1);
+ return 1;
}
Automaton automaton;
diff --git a/logd/src/tests/rotate/dummyserver.cpp b/logd/src/tests/rotate/dummyserver.cpp
index 4a52154f37c..f3458edaf80 100644
--- a/logd/src/tests/rotate/dummyserver.cpp
+++ b/logd/src/tests/rotate/dummyserver.cpp
@@ -9,11 +9,12 @@
#include <time.h>
#include <fcntl.h>
#include <vespa/vespalib/net/socket_address.h>
+#include <cstdlib>
void error(const char *msg)
{
perror(msg);
- exit(1);
+ std::_Exit(1);
}
int main(int /*argc*/, char ** /*argv*/)
diff --git a/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp b/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp
index e37a6fb2dcb..a149c6581ac 100644
--- a/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp
+++ b/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "cf-handler.h"
+#include <cstdlib>
#include <dirent.h>
#include <stdio.h>
#include <unistd.h>
@@ -122,12 +123,12 @@ CfHandler::start(const char *configId)
subscribe(configId, CONFIG_TIMEOUT_MS);
} catch (config::ConfigTimeoutException & ex) {
LOG(warning, "Timout getting config, please check your setup. Will exit and restart: %s", ex.getMessage().c_str());
- exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
} catch (config::InvalidConfigException& ex) {
LOG(error, "Fatal: Invalid configuration, please check your setup: %s", ex.getMessage().c_str());
- exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
} catch (config::ConfigRuntimeException& ex) {
LOG(error, "Fatal: Could not get config, please check your setup: %s", ex.getMessage().c_str());
- exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
}
}
diff --git a/logforwarder/src/apps/vespa-logforwarder-start/child-handler.cpp b/logforwarder/src/apps/vespa-logforwarder-start/child-handler.cpp
index c5c19aa2c3f..9a4fb5d1d29 100644
--- a/logforwarder/src/apps/vespa-logforwarder-start/child-handler.cpp
+++ b/logforwarder/src/apps/vespa-logforwarder-start/child-handler.cpp
@@ -8,6 +8,7 @@
#include <sys/wait.h>
#include <vector>
#include <string>
+#include <cstdlib>
#include <vespa/log/log.h>
LOG_SETUP(".child-handler");
@@ -44,7 +45,7 @@ runSplunk(const vespalib::string &prefix, std::vector<const char *> args)
execv(cargv[0], cargv);
// if execv fails:
perror(cargv[0]);
- exit(1);
+ std::_Exit(1);
}
LOG(debug, "child running with pid %d", (int)child);
int waitStatus = 0;
diff --git a/logforwarder/src/apps/vespa-logforwarder-start/main.cpp b/logforwarder/src/apps/vespa-logforwarder-start/main.cpp
index 8fc74fcac8e..859a8f4dd3f 100644
--- a/logforwarder/src/apps/vespa-logforwarder-start/main.cpp
+++ b/logforwarder/src/apps/vespa-logforwarder-start/main.cpp
@@ -30,7 +30,7 @@ main(int argc, char** argv)
int c = getopt(argc, argv, "c:");
if (c != 'c') {
LOG(error, "Usage: %s -c <config-id>", argv[0]);
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
Wrapper wrapper(optarg);
wrapper.run();
diff --git a/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp b/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp
index dcd3dce218b..c669f90ae2c 100644
--- a/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp
+++ b/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp
@@ -10,6 +10,7 @@
#include <vespa/fastos/app.h>
#include <sys/time.h>
#include <thread>
+#include <cstdlib>
#include <vespa/log/log.h>
LOG_SETUP("vespa-proton-cmd");
@@ -123,7 +124,7 @@ public:
if (!sbmirror.ready()) {
fprintf(stderr,
"ERROR: no data from service location broker\n");
- exit(1);
+ std::_Exit(1);
}
slobrok::api::MirrorAPI::SpecList specs = sbmirror.lookup(rtcPattern);
slobrok::api::MirrorAPI::SpecList specs2 = sbmirror.lookup(rtcPattern2);
@@ -140,7 +141,7 @@ public:
scanSpecs(specs3, me, service, spec, found);
if (found > 1) {
fprintf(stderr, "found more than one local RTC, you must use --id=<name>\n");
- exit(1);
+ std::_Exit(1);
}
if (found < 1) {
fprintf(stderr, "found no local RTC, you must use --id=<name> (list follows):\n");
@@ -148,12 +149,12 @@ public:
printf("RTC name %s with connection spec %s\n",
specs[j].first.c_str(), specs[j].second.c_str());
}
- exit(1);
+ std::_Exit(1);
}
return spec;
} catch (config::InvalidConfigException& e) {
fprintf(stderr, "ERROR: failed to get service location broker configuration\n");
- exit(1);
+ std::_Exit(1);
}
return "";
}
diff --git a/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp b/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp
index 90953f78c40..06fb5e71e06 100644
--- a/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp
+++ b/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp
@@ -15,6 +15,7 @@
#include <vespa/fastos/app.h>
#include <iostream>
#include <getopt.h>
+#include <cstdlib>
#include <vespa/log/log.h>
LOG_SETUP("vespa-index-inspect");
@@ -153,10 +154,8 @@ FieldOptions::validateFields(const Schema &schema)
i != ie; ++i) {
uint32_t fieldId = schema.getIndexFieldId(*i);
if (fieldId == Schema::UNKNOWN_FIELD_ID) {
- LOG(error,
- "No such field: %s",
- i->c_str());
- exit(1);
+ LOG(error, "No such field: %s", i->c_str());
+ std::_Exit(1);
}
_ids.push_back(fieldId);
}
@@ -465,7 +464,7 @@ ShowPostingListSubApp::showTransposedPostingList()
if (!schema.loadFromFile(schemaName)) {
LOG(error,
"Could not load schema from %s", schemaName.c_str());
- exit(1);
+ std::_Exit(1);
}
_fieldOptions.validateFields(schema);
if (!readDocIdLimit(schema))
@@ -538,14 +537,14 @@ ShowPostingListSubApp::showPostingList()
if (!schema.loadFromFile(schemaName)) {
LOG(error,
"Could not load schema from %s", schemaName.c_str());
- exit(1);
+ std::_Exit(1);
}
_fieldOptions.validateFields(schema);
if (_fieldOptions._ids.size() != 1) {
LOG(error,
"Wrong number of field arguments: %d",
static_cast<int>(_fieldOptions._ids.size()));
- exit(1);
+ std::_Exit(1);
}
SchemaUtil::IndexIterator it(schema, _fieldOptions._ids.front());
@@ -559,26 +558,22 @@ ShowPostingListSubApp::showPostingList()
if (_readmmap)
tuneFileRead.setWantMemoryMap();
if (!dict->open(dictName, tuneFileRead)) {
- LOG(error,
- "Could not open dictionary %s",
- dictName.c_str());
- exit(1);
+ LOG(error, "Could not open dictionary %s", dictName.c_str());
+ std::_Exit(1);
}
std::unique_ptr<PostingListFileRandRead> postingfile(new Zc4PosOccRandRead);
std::string mangledName = _indexDir + "/" + shortName +
"/posocc.dat.compressed";
if (!postingfile->open(mangledName, tuneFileRead)) {
- LOG(error,
- "Could not open posting list file %s",
- mangledName.c_str());
- exit(1);
+ LOG(error, "Could not open posting list file %s", mangledName.c_str());
+ std::_Exit(1);
}
PostingListOffsetAndCounts offsetAndCounts;
uint64_t wordNum = 0;
bool res = dict->lookup(_word, wordNum, offsetAndCounts);
if (!res) {
LOG(warning, "Unknown word %s", _word.c_str());
- exit(1);
+ std::_Exit(1);
}
if (_verbose) {
LOG(info,
@@ -650,15 +645,13 @@ ShowPostingListSubApp::showPostingList()
}
if (!postingfile->close()) {
- LOG(error,
- "Could not close posting list file %s",
+ LOG(error, "Could not close posting list file %s",
mangledName.c_str());
- exit(1);
+ std::_Exit(1);
}
if (!dict->close()) {
- LOG(error,
- "Could not close dictionary %s", dictName.c_str());
- exit(1);
+ LOG(error, "Could not close dictionary %s", dictName.c_str());
+ std::_Exit(1);
}
}
@@ -797,16 +790,14 @@ DumpWordsSubApp::dumpWords()
search::index::Schema schema;
std::string schemaName = _indexDir + "/schema.txt";
if (!schema.loadFromFile(schemaName)) {
- LOG(error,
- "Could not load schema from %s", schemaName.c_str());
- exit(1);
+ LOG(error, "Could not load schema from %s", schemaName.c_str());
+ std::_Exit(1);
}
_fieldOptions.validateFields(schema);
if (_fieldOptions._ids.size() != 1) {
- LOG(error,
- "Wrong number of field arguments: %d",
+ LOG(error, "Wrong number of field arguments: %d",
static_cast<int>(_fieldOptions._ids.size()));
- exit(1);
+ std::_Exit(1);
}
SchemaUtil::IndexIterator index(schema, _fieldOptions._ids[0]);
@@ -815,9 +806,8 @@ DumpWordsSubApp::dumpWords()
std::string wordListName = fieldDir + "/dictionary";
search::TuneFileSeqRead tuneFileRead;
if (!wordList.open(wordListName, tuneFileRead)) {
- LOG(error,
- "Could not open wordlist %s", wordListName.c_str());
- exit(1);
+ LOG(error, "Could not open wordlist %s", wordListName.c_str());
+ std::_Exit(1);
}
uint64_t wordNum = 0;
vespalib::string word;
@@ -838,9 +828,8 @@ DumpWordsSubApp::dumpWords()
std::cout << '\n';
}
if (!wordList.close()) {
- LOG(error,
- "Could not close wordlist %s", wordListName.c_str());
- exit(1);
+ LOG(error, "Could not close wordlist %s", wordListName.c_str());
+ std::_Exit(1);
}
}
diff --git a/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp b/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp
index 1e10d94bb18..9c896396de3 100644
--- a/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp
+++ b/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp
@@ -82,7 +82,7 @@ void read_vector_file(MallocPointVector *p) {
int fd = open(fn.c_str(), O_RDONLY);
if (fd < 0) {
perror(fn.c_str());
- exit(1);
+ std::_Exit(1);
}
int d;
size_t rv;
diff --git a/searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp b/searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp
index 9b2510ac3df..4abbe7d2613 100644
--- a/searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp
+++ b/searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp
@@ -18,7 +18,7 @@ ExtractKeywordsTest::Main()
bool failed = false;
if (_argc == 1)
- Usage(_argv[0]);
+ return Usage(_argv[0]);
// default initialize to not run any tests.
for (int n = 0; n < NUMTESTS; n++)
@@ -271,7 +271,7 @@ ExtractKeywordsTest::RunTest(int testno, bool verify)
return result;
}
-void
+int
ExtractKeywordsTest::Usage(char *progname)
{
printf("%s {testnospec}+\n\
@@ -279,7 +279,7 @@ ExtractKeywordsTest::Usage(char *progname)
num: single test\n\
num-num: inclusive range (open range permitted)\n",progname);
printf("There are tests from %d to %d\n\n", 0, NUMTESTS-1);
- exit(-1);
+ return EXIT_FAILURE;
}
int
diff --git a/searchsummary/src/tests/extractkeywords/extractkeywordstest.h b/searchsummary/src/tests/extractkeywords/extractkeywordstest.h
index e3c79bfc202..739ba4bf1ff 100644
--- a/searchsummary/src/tests/extractkeywords/extractkeywordstest.h
+++ b/searchsummary/src/tests/extractkeywords/extractkeywordstest.h
@@ -15,7 +15,7 @@ private:
search::docsummary::KeywordExtractor *_extractor;
int Main() override;
- void Usage(char *progname);
+ int Usage(char *progname);
bool ShowResult(int testNo, const char *actual, const char *correct);
bool RunTest(int i, bool verify);
diff --git a/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp b/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp
index fbaa5581173..04a811494c9 100644
--- a/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp
+++ b/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp
@@ -3,6 +3,7 @@
#include <vespa/vespalib/util/shutdownguard.h>
#include <unistd.h>
#include <sys/wait.h>
+#include <cstdlib>
using namespace vespalib;
@@ -23,7 +24,7 @@ Test::Main()
for (int i = 0; i < 1000; ++i) {
std::this_thread::sleep_for(20ms);
}
- exit(0);
+ std::_Exit(0);
}
for (int i = 0; i < 1000; ++i) {
std::this_thread::sleep_for(20ms);
diff --git a/storage/src/vespa/storage/tools/generatedistributionbits.cpp b/storage/src/vespa/storage/tools/generatedistributionbits.cpp
index 98c5e56b90c..0885483f674 100644
--- a/storage/src/vespa/storage/tools/generatedistributionbits.cpp
+++ b/storage/src/vespa/storage/tools/generatedistributionbits.cpp
@@ -128,7 +128,7 @@ int main(int argc, char** argv) {
std::cerr << e.getMessage() << "\n\n";
o.writeSyntaxPage(std::cerr);
std::cerr << "\n";
- exit(1);
+ return 1;
}
o.finalize();
if (o.printHtml) { std::cout << "<b>"; }
diff --git a/storageapi/src/vespa/storageapi/app/getbucketid.cpp b/storageapi/src/vespa/storageapi/app/getbucketid.cpp
index 25c2fd2fc37..4f6552ac3f0 100644
--- a/storageapi/src/vespa/storageapi/app/getbucketid.cpp
+++ b/storageapi/src/vespa/storageapi/app/getbucketid.cpp
@@ -7,7 +7,7 @@ int main(int argc, char** argv)
{
if (argc != 2) {
std::cerr << "Usage: getbucketid <documentid>\n";
- exit(1);
+ return 1;
}
document::BucketIdFactory factory;
document::BucketId id = factory.getBucketId(document::DocumentId(argv[1]));
diff --git a/storageserver/src/apps/storaged/storage.cpp b/storageserver/src/apps/storaged/storage.cpp
index e789fd68ecb..903c61875ed 100644
--- a/storageserver/src/apps/storaged/storage.cpp
+++ b/storageserver/src/apps/storaged/storage.cpp
@@ -21,6 +21,7 @@
#include <vespa/fastos/app.h>
#include <iostream>
#include <csignal>
+#include <cstdlib>
#include <vespa/log/log.h>
LOG_SETUP("vds.application");
@@ -109,11 +110,11 @@ bool StorageApp::Init()
} catch (vespalib::InvalidCommandLineArgumentsException& e) {
std::cerr << e.getMessage() << "\n\n";
writeSyntaxPage(std::cerr);
- exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
}
if (_showSyntax) {
writeSyntaxPage(std::cerr);
- exit(0);
+ std::_Exit(0);
}
return true;
}
diff --git a/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp b/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp
index 1b8f31f0d03..082aa83c3da 100644
--- a/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp
+++ b/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp
@@ -15,6 +15,7 @@
#include <sstream>
#include <iostream>
#include <thread>
+#include <cstdlib>
#include <sys/time.h>
#include <vespa/log/log.h>
@@ -128,7 +129,7 @@ struct Options : public vespalib::ProgramOptions {
_clusterName = _cluster.getName();
} catch (const vespaclient::ClusterList::ClusterNotFoundException& e) {
std::cerr << e.getMessage() << "\n";
- exit(1);
+ std::_Exit(1);
}
return true;
}
diff --git a/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp b/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp
index 3041627b2d0..0141e32e435 100644
--- a/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp
+++ b/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp
@@ -310,13 +310,13 @@ int main(int argc, char *argv[])
} else {
std::vector<pthread_t> threads(numThreads);
for (size_t j(0); j < numThreads; j++) {
- pthread_create(&threads[j], NULL, (VFUNC)runBenchMark, &indirectSlotVector);
+ pthread_create(&threads[j], NULL, (VFUNC)runBenchMark, &indirectSlotVector);
}
for (size_t j(0); j < numThreads; j++) {
pthread_join(threads[j], NULL);
}
}
- break;
+ break;
default:
printf("'m' = %s\n", description[type]);
printf("'M' = %s\n", description[type]);
@@ -327,11 +327,10 @@ int main(int argc, char *argv[])
printf("'g' = %s\n", description[type]);
printf("'G' = %s\n", description[type]);
printf("'J' = %s\n", description[type]);
- printf("Unspecified type %c. Running map benchmark\n", type);
- exit(1);
- break;
+ printf("Unspecified type %c.\n", type);
+ return 1;
}
}
printf("Running test '%c' = %s, result = %ld unique values\n", type, description[type], uniq);
+ return 0;
}
-
diff --git a/vespalog/src/logctl/logctl.cpp b/vespalog/src/logctl/logctl.cpp
index 950b7929a50..14137a79687 100644
--- a/vespalog/src/logctl/logctl.cpp
+++ b/vespalog/src/logctl/logctl.cpp
@@ -132,7 +132,7 @@ main(int argc, char **argv)
break;
case 'h':
usage(argv[0]);
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
}
@@ -154,17 +154,17 @@ main(int argc, char **argv)
services = findAllFiles(dir);
if (doOnlyFile) {
fprintf(stderr, "-f and -a options cannot be used at the same time\n");
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
// No log control files exist
if (services.empty()) {
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
} else {
if (optind >= argc) {
usage(argv[0]);
fprintf(stderr, "ERROR: Missing service argument!\n");
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
char *service = strdup(argv[optind]);
++optind;
@@ -195,7 +195,7 @@ main(int argc, char **argv)
if (argc > optind) {
usage(argv[0]);
fprintf(stderr, "ERROR: Too many arguments!\n\n");
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
bool hadFailure = false;
@@ -221,12 +221,12 @@ main(int argc, char **argv)
hadFailure = true;
}
}
- if (hadFailure) exit(EXIT_FAILURE);
+ if (hadFailure) return EXIT_FAILURE;
if (! hadSuccess) {
fprintf(stderr, "no logcontrol files updates\n");
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
static void
diff --git a/vespalog/src/logger/logger.cpp b/vespalog/src/logger/logger.cpp
index 80a2f4c0aa7..0b33f251797 100644
--- a/vespalog/src/logger/logger.cpp
+++ b/vespalog/src/logger/logger.cpp
@@ -42,7 +42,7 @@ int main(int argc, char *argv[])
default:
fprintf(stderr, "Usage: foo | %s [-s service] [-c component]"
"[-l level] [-p pid]\n", argv[0]);
- exit(ch != 'h');
+ return (ch == 'h') ? EXIT_SUCCESS : EXIT_FAILURE;
}
}
diff --git a/vespalog/src/logger/logreplay.c b/vespalog/src/logger/logreplay.c
index 70a1b9a08a9..7a920a916a4 100644
--- a/vespalog/src/logger/logreplay.c
+++ b/vespalog/src/logger/logreplay.c
@@ -19,7 +19,7 @@ main(int argc, char **argv)
"Replays a vespa log file with the same timing delta between each log message.\n"
"Reprints the log messages without timestamps.\n\n",
argv[0]);
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
while (fgets(line, sizeof line, stdin)) {
@@ -54,5 +54,5 @@ main(int argc, char **argv)
fwrite(s, strlen(s), 1, stdout);
fflush(stdout);
}
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/vespalog/src/logger/runserver.cpp b/vespalog/src/logger/runserver.cpp
index e58565f78b9..f1754e84272 100644
--- a/vespalog/src/logger/runserver.cpp
+++ b/vespalog/src/logger/runserver.cpp
@@ -102,7 +102,7 @@ PidFile::writePid()
if (didtruncate != 0) {
fprintf(stderr, "could not truncate pid file %s: %s\n",
_pidfile, strerror(errno));
- exit(1);
+ std::_Exit(1);
}
char buf[100];
sprintf(buf, "%d\n", getpid());
@@ -111,7 +111,7 @@ PidFile::writePid()
if (didw != l) {
fprintf(stderr, "could not write pid to %s: %s\n",
_pidfile, strerror(errno));
- exit(1);
+ std::_Exit(1);
}
LOG(debug, "wrote '%s' to %s (fd %d)", buf, _pidfile, _fd);
}
@@ -168,7 +168,7 @@ int loop(const char *svc, char * const * run)
if (pipe(pstdout) < 0 || pipe(pstderr) < 0) {
LOG(error, "pipe: %s", strerror(errno));
- exit(1);
+ std::_Exit(1);
}
LOG(debug, "stdout pipe %d <- %d; stderr pipe %d <- %d",
pstdout[0], pstdout[1],
@@ -188,11 +188,11 @@ int loop(const char *svc, char * const * run)
close(pstderr[1]);
execvp(run[0], run);
LOG(error, "exec %s: %s", run[0], strerror(errno));
- exit(1);
+ std::_Exit(1);
}
if (child < 0) {
LOG(error, "fork(): %s", strerror(errno));
- exit(1);
+ std::_Exit(1);
}
// I am the parent process
@@ -325,13 +325,13 @@ int loop(const char *svc, char * const * run)
return WEXITSTATUS(wstat);
}
-void usage(char *prog, int es)
+int usage(char *prog, int es)
{
fprintf(stderr, "Usage: %s\n"
" [-s service] [-r restartinterval] [-p pidfile]"
" program [args ...]\n"
"or: [-p pidfile] [-k killcmd] -S\n", prog);
- exit(es);
+ return es;
}
int main(int argc, char *argv[])
@@ -363,7 +363,7 @@ int main(int argc, char *argv[])
killcmd = optarg;
break;
default:
- usage(argv[0], ch != 'h');
+ return usage(argv[0], ch != 'h');
}
}
@@ -374,7 +374,7 @@ int main(int argc, char *argv[])
}
if (chdir(envROOT) != 0) {
fprintf(stderr, "Cannot chdir to %s: %s\n", envROOT, strerror(errno));
- exit(1);
+ return 1;
}
PidFile mypf(pidfile);
@@ -393,7 +393,7 @@ int main(int argc, char *argv[])
if (killpg(pid, SIGTERM) != 0) {
fprintf(stderr, "could not signal %d: %s\n", pid,
strerror(errno));
- exit(1);
+ return 1;
}
}
fprintf(stdout, "Waiting for exit (up to 60 seconds)\n");
@@ -421,16 +421,16 @@ int main(int argc, char *argv[])
service, pidfile);
}
mypf.cleanUp();
- exit(0);
+ return 0;
}
if (optind >= argc || killcmd != NULL) {
- usage(argv[0], 1);
+ return usage(argv[0], 1);
}
if (mypf.anotherRunning()) {
fprintf(stderr, "runserver already running with pid %d\n",
mypf.readPid());
- exit(0);
+ return 0;
}
if (!mypf.writeOpen()) {
@@ -443,17 +443,17 @@ int main(int argc, char *argv[])
close(0);
if (open("/dev/null", O_RDONLY) != 0) {
perror("open /dev/null for reading failed");
- exit(1);
+ std::_Exit(1);
}
close(1);
if (open("/dev/null", O_WRONLY) != 1) {
perror("open /dev/null for writing failed");
- exit(1);
+ std::_Exit(1);
}
dup2(1, 2);
if (setsid() < 0) {
perror("setsid");
- exit(1);
+ std::_Exit(1);
}
struct sigaction act;
struct sigaction oact;
@@ -482,15 +482,14 @@ int main(int argc, char *argv[])
} while (!gotstopsig && restart > 0);
} catch (MsgException& ex) {
LOG(error, "exception: '%s'", ex.what());
- exit(1);
+ return 1;
}
if (restart > 0) {
LOG(debug, "final exit status: %d", stat);
}
mypf.cleanUp();
- exit(stat);
+ return stat;
}
-
if (rsp < 0) {
perror("fork");
return 1;
diff --git a/vespalog/src/test/bufferedlogskiptest.cpp b/vespalog/src/test/bufferedlogskiptest.cpp
index 21a3044e676..55815480e97 100644
--- a/vespalog/src/test/bufferedlogskiptest.cpp
+++ b/vespalog/src/test/bufferedlogskiptest.cpp
@@ -5,6 +5,7 @@
#include <fstream>
#include <iostream>
#include <unistd.h>
+#include <cstdlib>
LOG_SETUP("bufferedlogskiptest");
@@ -53,10 +54,9 @@ void testSkipBufferOnDebug(const std::string& file, uint64_t & timer)
[[maybe_unused]] int system_result =
system(("diff -u " + file
+ " bufferedlogskiptest.skipped.log").c_str());
- exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
}
unlink(file.c_str());
-
}
void reset(uint64_t & timer) {
@@ -71,7 +71,7 @@ main(int argc, char **argv)
{
if (argc != 2) {
std::cerr << "bufferedlogskiptest must be called with one argument\n";
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
ns_log::Logger::fakePid = true;
uint64_t timer;
@@ -81,5 +81,5 @@ main(int argc, char **argv)
reset(timer);
testSkipBufferOnDebug(argv[1], timer);
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/vespalog/src/test/bufferedlogtest.cpp b/vespalog/src/test/bufferedlogtest.cpp
index 09e103986ac..4035e98653f 100644
--- a/vespalog/src/test/bufferedlogtest.cpp
+++ b/vespalog/src/test/bufferedlogtest.cpp
@@ -8,6 +8,7 @@
#include <fstream>
#include <iostream>
#include <unistd.h>
+#include <cstdlib>
LOG_SETUP("bufferedlogtest");
@@ -98,7 +99,7 @@ void testThatEntriesWithHighCountIsKept(const std::string& file, uint64_t& timer
[[maybe_unused]] int systemResult =
system(("diff -u " + file + " bufferedlogtest.highcountkept.log")
.c_str());
- exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
}
unlink(file.c_str());
}
@@ -134,7 +135,7 @@ void testThatEntriesWithHighCountsAreEventuallyRemoved(
[[maybe_unused]] int systemResult =
system(("diff -u " + file + " bufferedlogtest.highcountexpire.log")
.c_str());
- exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
}
unlink(file.c_str());
}
@@ -168,7 +169,7 @@ void testThatEntriesExpire(
<< "testThatEntriesExpire\n";
[[maybe_unused]] int systemResult =
system(("diff -u " + file + " bufferedlogtest.expire.log").c_str());
- exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
}
unlink(file.c_str());
}
@@ -237,7 +238,7 @@ void testThatHighCountEntriesDontStarveOthers(
<< "testThatHighCountEntriesDontStarveOthers\n";
[[maybe_unused]] int systemResult =
system(("diff -u " + file + " bufferedlogtest.nostarve.log").c_str());
- exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
}
unlink(file.c_str());
}
@@ -270,7 +271,7 @@ void testNoTokenMatchAcrossComponents(const std::string& file,
[[maybe_unused]] int systemResult =
system(("diff -u " + file
+ " bufferedlogtest.tokenacrossloggers.log").c_str());
- exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
}
unlink(file.c_str());
}
@@ -299,7 +300,7 @@ void testLogLocationAsToken(const std::string& file, uint64_t& timer)
[[maybe_unused]] int systemResult =
system(("diff -u " + file
+ " bufferedlogtest.locationastoken.log").c_str());
- exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
}
unlink(file.c_str());
}
@@ -328,7 +329,7 @@ void testLogMessageAsToken(const std::string& file, uint64_t& timer)
[[maybe_unused]] int systemResult =
system(("diff -u " + file
+ " bufferedlogtest.messageastoken.log").c_str());
- exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
}
unlink(file.c_str());
}
@@ -363,7 +364,7 @@ void testNonBufferedLoggerTriggersBufferedLogTrim(const std::string& file,
[[maybe_unused]] int systemResult =
system(("diff -u " + file
+ " bufferedlogtest.trimcache.log").c_str());
- exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
}
unlink(file.c_str());
@@ -380,7 +381,7 @@ main(int argc, char **argv)
{
if (argc != 2) {
std::cerr << "bufferedlogtest must be called with one argument\n";
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
ns_log::Logger::fakePid = true;
ns_log::BufferedLogger::logger.setMaxCacheSize(10);
@@ -405,5 +406,5 @@ main(int argc, char **argv)
reset(timer);
testNonBufferedLoggerTriggersBufferedLogTrim(argv[1], timer);
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/vespalog/src/test/logtest.cpp b/vespalog/src/test/logtest.cpp
index 42b7bfc6ef9..a95bea9e31c 100644
--- a/vespalog/src/test/logtest.cpp
+++ b/vespalog/src/test/logtest.cpp
@@ -33,5 +33,5 @@ main(int, char **argv)
LOG(info, "Exiting.");
EV_STOPPING("logtest", "clean exit");
EV_STOPPED("logtest", getpid(), 0);
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/vespalog/src/test/rejectfiltertest.cpp b/vespalog/src/test/rejectfiltertest.cpp
index d79d621c780..3125c05b959 100644
--- a/vespalog/src/test/rejectfiltertest.cpp
+++ b/vespalog/src/test/rejectfiltertest.cpp
@@ -5,6 +5,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <iostream>
+#include <cstdlib>
using ns_log::RejectFilter;
using ns_log::Logger;
@@ -15,7 +16,7 @@ assertShouldNotReject(RejectFilter & filter, Logger::LogLevel level, const char
std::cerr << "Filter should not reject level '" << Logger::levelName(level) << "' message '" << (msg == NULL ? "NULL" : msg) << "' ...: ";
if (filter.shouldReject(level, msg)) {
std::cerr << "Failed!\n";
- exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
}
std::cerr << "Success!\n";
}
@@ -26,7 +27,7 @@ assertShouldReject(RejectFilter & filter, Logger::LogLevel level, const char * m
std::cerr << "Filter should reject level '" << Logger::levelName(level) << "' message '" << (msg == NULL ? "NULL" : msg) << "' ...: ";
if (!filter.shouldReject(level, msg)) {
std::cerr << "Failed!\n";
- exit(EXIT_FAILURE);
+ std::_Exit(EXIT_FAILURE);
}
std::cerr << "Success!\n";
}
@@ -53,5 +54,5 @@ main(int argc, char **argv)
assertShouldNotReject(defaultFilter, Logger::warning, "foobar");
assertShouldNotReject(defaultFilter, Logger::event, NULL);
assertShouldReject(defaultFilter, Logger::warning, "E 18-140313.398540 10727 18/11/2012 14:03:13 yjava_preload.so: [preload.c:670] Accept failed: -1 (4)");
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/vespalog/src/test/simple/logtest.cpp b/vespalog/src/test/simple/logtest.cpp
index 020c97dd1a8..7951b488052 100644
--- a/vespalog/src/test/simple/logtest.cpp
+++ b/vespalog/src/test/simple/logtest.cpp
@@ -33,5 +33,5 @@ main(int, char **argv)
LOG(info, "Exiting.");
EV_STOPPING("logtest", "clean exit");
EV_STOPPED("logtest", getpid(), 0);
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/vespalog/src/test/threads/testthreads.cpp b/vespalog/src/test/threads/testthreads.cpp
index ab7ddad3da7..465d2c6e3f8 100644
--- a/vespalog/src/test/threads/testthreads.cpp
+++ b/vespalog/src/test/threads/testthreads.cpp
@@ -9,6 +9,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
+#include <cstdlib>
using std::string;
using namespace std::chrono_literals;
@@ -44,18 +45,18 @@ FileThread::Run(FastOS_ThreadInterface *, void *)
int fd = open(_file.c_str(), O_RDWR | O_CREAT | O_APPEND, 0644);
if (fd == -1) {
fprintf(stderr, "open failed: %s\n", strerror(errno));
- exit(1);
+ std::_Exit(1);
}
std::this_thread::sleep_for(5ms);
struct stat buf;
fstat(fd, &buf);
if (buf.st_size != 0) {
fprintf(stderr, "%s isn't empty anymore\n", _file.c_str());
- exit(1);
+ std::_Exit(1);
}
if (close(fd) != 0) {
fprintf(stderr, "close of %d failed: %s\n", fd, strerror(errno));
- exit(1);
+ std::_Exit(1);
}
}
}
diff --git a/vespalog/src/vespa-logfmt/logfilter.c b/vespalog/src/vespa-logfmt/logfilter.c
index 2db108771ee..1af97751011 100644
--- a/vespalog/src/vespa-logfmt/logfilter.c
+++ b/vespalog/src/vespa-logfmt/logfilter.c
@@ -5,6 +5,7 @@
#include <sys/wait.h>
#include <unistd.h>
#include <csignal>
+#include <cstdlib>
int main(int argc, char *argv[])
{
@@ -15,7 +16,7 @@ int main(int argc, char *argv[])
if (argc < 3) {
fprintf(stderr, "Usage: %s logfmt prog [...]\n", argv[0]);
- exit(1);
+ return 1;
}
pipe(lfpipe);
@@ -29,11 +30,11 @@ int main(int argc, char *argv[])
}
execlp(argv[1], argv[1], "-", (const char *)NULL);
perror("exec logfmt failed");
- exit(1);
+ std::_Exit(1);
}
if (lfmtpid < 0) {
perror("fork failed");
- exit(1);
+ return 1;
}
close(lfpipe[0]);
@@ -50,11 +51,11 @@ int main(int argc, char *argv[])
argv[i-2] = NULL;
execvp(argv[0], argv);
perror("exec program failed");
- exit(1);
+ std::_Exit(1);
}
if (progpid < 0) {
perror("fork failed");
- exit(1);
+ return 1;
}
close(lfpipe[1]);
@@ -74,5 +75,5 @@ int main(int argc, char *argv[])
kill(getpid(), sig);
}
/* should not get here */
- exit(1);
+ return 1;
}