diff options
| author | Riccardo Spagni <ric@spagni.net> | 2017-07-19 11:50:38 +0200 |
|---|---|---|
| committer | Riccardo Spagni <ric@spagni.net> | 2017-07-19 11:50:38 +0200 |
| commit | fed3430b701c6bf7d5e07449263cb11a65f8243d (patch) | |
| tree | 1d30b58df3ed994928501f80e9f0b6e446ce30cb | |
| parent | 921ebdce45ccadd3b5a707b8e71ce4a714d06702 (diff) | |
| parent | 33d17c37e80acc8d810d870eee5f5aac202f7804 (diff) | |
| download | monzero-core-fed3430b701c6bf7d5e07449263cb11a65f8243d.tar.gz monzero-core-fed3430b701c6bf7d5e07449263cb11a65f8243d.tar.xz monzero-core-fed3430b701c6bf7d5e07449263cb11a65f8243d.zip | |
Merge pull request #2166
33d17c37 Don't hardcode /tmp (Howard Chu)
| -rw-r--r-- | src/daemonizer/posix_fork.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/daemonizer/posix_fork.cpp b/src/daemonizer/posix_fork.cpp index 949c0f593..d9b4a6d0e 100644 --- a/src/daemonizer/posix_fork.cpp +++ b/src/daemonizer/posix_fork.cpp @@ -14,6 +14,10 @@ #include <string> #include <sys/stat.h> +#ifndef TMPDIR +#define TMPDIR "/tmp" +#endif + namespace posix { namespace { @@ -76,12 +80,16 @@ void fork() } // Send standard output to a log file. - const char* output = "/tmp/bitmonero.daemon.stdout.stderr"; + const char *tmpdir = getenv("TMPDIR"); + if (!tmpdir) + tmpdir = TMPDIR; + std::string output = tmpdir; + output += "/bitmonero.daemon.stdout.stderr"; const int flags = O_WRONLY | O_CREAT | O_APPEND; const mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; - if (open(output, flags, mode) < 0) + if (open(output.c_str(), flags, mode) < 0) { - quit("Unable to open output file: " + std::string(output)); + quit("Unable to open output file: " + output); } // Also send standard error to the same log file. |
