summaryrefslogtreecommitdiffstats
path: root/daemon/daemon.c
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2024-01-31 12:47:20 +0200
committerGitHub <noreply@github.com>2024-01-31 12:47:20 +0200
commit841d9f125afb346819660ede9388313b92cefb59 (patch)
treed794d1f08ad4ddb6c3998174818f8e09601ac710 /daemon/daemon.c
parent2371fec7a3be30bc56ef5530bfab82361ca446f7 (diff)
add the CLOEXEC flag to all sockets and files (#16881)
* add the CLOEXEC flag to all sockets and files * add network-viewer to apps.plugin; min update frequency 5 seconds
Diffstat (limited to 'daemon/daemon.c')
-rw-r--r--daemon/daemon.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/daemon/daemon.c b/daemon/daemon.c
index 3f5a04029e..7dcca18cb5 100644
--- a/daemon/daemon.c
+++ b/daemon/daemon.c
@@ -245,7 +245,7 @@ static void oom_score_adj(void) {
}
int written = 0;
- int fd = open("/proc/self/oom_score_adj", O_WRONLY);
+ int fd = open("/proc/self/oom_score_adj", O_WRONLY | O_CLOEXEC);
if(fd != -1) {
snprintfz(buf, sizeof(buf) - 1, "%d", (int)wanted_score);
ssize_t len = strlen(buf);
@@ -478,7 +478,7 @@ int become_daemon(int dont_fork, const char *user)
// generate our pid file
int pidfd = -1;
if(pidfile[0]) {
- pidfd = open(pidfile, O_WRONLY | O_CREAT, 0644);
+ pidfd = open(pidfile, O_WRONLY | O_CREAT | O_CLOEXEC, 0644);
if(pidfd >= 0) {
if(ftruncate(pidfd, 0) != 0)
netdata_log_error("Cannot truncate pidfile '%s'.", pidfile);