wownero/src/daemonizer
redfish ce6b83128e daemonizer: posix: keep parent's working dir and umask
Keep the working directory (and umask) inherited from
the parent. Otherwise, it's impossible to control
the working directory of the daemon (from systemd, for
example).

Furthermoer, bitmonerod attempts to create logging directories and files
*in current working directory*. This fails due to permission denied and
generates a (caught, nonfatal) exception. Below is the strace with this
patch applied (so, no `chdir("/")`), showing successful opens at `log/`
relative path. Without this patch they fail (sorry, didn't save the
trace).

```
28911 getcwd("/.../bitmonero", 128) = 25
28911 stat64("/var/lib/bitmonero/.bitmonero", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
28911 stat64("/etc/bitmonerod.conf", {st_mode=S_IFREG|0644, st_size=244, ...}) = 0
28911 open("/etc/bitmonerod.conf", O_RDONLY|O_LARGEFILE) = 3
28911 open("/var/log/bitmonero/bitmonero.log", O_WRONLY|O_CREAT|O_APPEND|O_LARGEFILE, 0666) = 3
28911 stat64("log", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
28911 stat64("log/dbg", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
28911 open("log/dbg/main.log", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 4
```
The reasoning of chdir("/") in order to prevent the daemon from holding
a filesystem in busy state is not compelling at all: the choice of
working directory for the daemon is the user's business not the
daemon's.
2016-07-09 20:16:44 -04:00
..
CMakeLists.txt updated copyright year 2015-12-31 08:39:56 +02:00
daemonizer.h updated copyright year 2015-12-31 08:39:56 +02:00
posix_daemonizer.inl update version 2015-12-31 23:12:13 +02:00
posix_fork.cpp daemonizer: posix: keep parent's working dir and umask 2016-07-09 20:16:44 -04:00
posix_fork.h updated copyright year 2015-12-31 08:39:56 +02:00
windows_daemonizer.inl update version 2015-12-31 23:12:13 +02:00
windows_service_runner.h Use boost::thread instead of std::thread 2016-03-11 15:09:50 +00:00
windows_service.cpp Use boost::thread instead of std::thread 2016-03-11 15:09:50 +00:00
windows_service.h updated copyright year 2015-12-31 08:39:56 +02:00