Merge pull request #511 from eeff/eeff/fix

fix: neuron daemon lock file permission problem
This commit is contained in:
fengzeroz
2022-05-27 09:27:04 +08:00
committed by GitHub
+8 -1
View File
@@ -30,6 +30,8 @@
#include <stdlib.h>
#include <string.h>
#include "neuron/log.h"
#include "daemon.h"
void daemonize()
@@ -100,9 +102,12 @@ int neuron_already_running()
int ret = -1;
ssize_t size = -1;
umask(0);
fd = open(NEURON_DAEMON_LOCK_FNAME, O_RDWR | O_CREAT,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (fd < 0) {
log_error("cannot open %s reason: %s\n", NEURON_DAEMON_LOCK_FNAME,
strerror(errno));
exit(1);
}
@@ -113,6 +118,8 @@ int neuron_already_running()
close(fd);
return 1;
}
log_error("cannot lock %s reason: %s\n", NEURON_DAEMON_LOCK_FNAME,
strerror(errno));
exit(1);
}