diff options
author | Arne Juul <arnej@verizonmedia.com> | 2020-07-02 12:33:40 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2020-07-03 08:02:39 +0000 |
commit | 8ee299a551980d8e4a0b51ca7685c3a70a4bd2bd (patch) | |
tree | 985d6aaf6cabb4b4d1a8f70437473fc3957775de | |
parent | 5faea094d0ba4566ab4a63ce577d0c0fa76d60d4 (diff) |
avoid naked exit
-rw-r--r-- | fastlib/src/vespa/fastlib/text/apps/extcase.cpp | 2 | ||||
-rw-r--r-- | fastos/src/vespa/fastos/file.cpp | 7 | ||||
-rw-r--r-- | fastos/src/vespa/fastos/unix_ipc.cpp | 9 | ||||
-rw-r--r-- | fastos/src/vespa/fastos/unix_process.cpp | 9 |
4 files changed, 14 insertions, 13 deletions
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; |