mirror of
https://github.com/emqx/neuron.git
synced 2026-10-27 04:19:50 +08:00
Merge pull request #511 from eeff/eeff/fix
fix: neuron daemon lock file permission problem
This commit is contained in:
+8
-1
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user