mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-30 14:53:27 +01:00
Merge pull request #897
ce6b831
daemonizer: posix: keep parent's working dir and umask (redfish)
This commit is contained in:
commit
992b6cce06
@ -50,20 +50,6 @@ void fork()
|
|||||||
// terminal.
|
// terminal.
|
||||||
setsid();
|
setsid();
|
||||||
|
|
||||||
// A process inherits its working directory from its parent. This could be
|
|
||||||
// on a mounted filesystem, which means that the running daemon would
|
|
||||||
// prevent this filesystem from being unmounted. Changing to the root
|
|
||||||
// directory avoids this problem.
|
|
||||||
if (chdir("/") < 0)
|
|
||||||
{
|
|
||||||
quit("Unable to change working directory to root");
|
|
||||||
}
|
|
||||||
|
|
||||||
// The file mode creation mask is also inherited from the parent process.
|
|
||||||
// We don't want to restrict the permissions on files created by the
|
|
||||||
// daemon, so the mask is cleared.
|
|
||||||
umask(0);
|
|
||||||
|
|
||||||
// A second fork ensures the process cannot acquire a controlling terminal.
|
// A second fork ensures the process cannot acquire a controlling terminal.
|
||||||
if (pid_t pid = ::fork())
|
if (pid_t pid = ::fork())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user