From f80df71d672b7b2ed7df0a6eb9b7c35978b9b89e Mon Sep 17 00:00:00 2001 From: eeff <33566201+eeff@users.noreply.github.com> Date: Tue, 21 Nov 2023 14:40:54 +0800 Subject: [PATCH] fix: pid file work around fs.protected_regular --- src/daemon.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/daemon.c b/src/daemon.c index d3569c64..381e2f9e 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -149,9 +149,14 @@ int neuron_already_running() fd = open(NEURON_DAEMON_LOCK_FNAME, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if (fd < 0) { - nlog_error("cannot open %s reason: %s\n", NEURON_DAEMON_LOCK_FNAME, - strerror(errno)); - exit(1); + // work around fs.protected_regular + fd = open(NEURON_DAEMON_LOCK_FNAME, O_RDWR, + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + if (fd < 0) { + nlog_error("cannot open %s reason: %s\n", NEURON_DAEMON_LOCK_FNAME, + strerror(errno)); + exit(1); + } } // try to lock file