Make all fopen() calls use O_CLOEXEC

by adding "e" to the mode strings.
This commit is contained in:
Demi Marie Obenour 2022-09-23 10:40:55 -04:00 committed by Wim Taymans
parent 400860f63c
commit bb4f274ae0
10 changed files with 23 additions and 23 deletions

View file

@ -195,7 +195,7 @@ int create_pid_file(void) {
strcat(pid_file, "/pid");
if ((f = fopen(pid_file, "w")) == NULL) {
if ((f = fopen(pid_file, "we")) == NULL) {
res = -errno;
pw_log_error("failed to open pid file: %m");
return res;

View file

@ -514,7 +514,7 @@ static int draw_graph(struct data *d, const char *path)
fputs(d->dot_str, stdout);
} else {
/* open the file */
fp = fopen(path, "w");
fp = fopen(path, "we");
if (fp == NULL) {
printf("open error: could not open %s for writing\n", path);
return -1;

View file

@ -262,7 +262,7 @@ static void dump_scripts(struct data *d)
printf("\ndumping scripts for %d followers\n", d->n_followers);
out = fopen("Timing1.plot", "w");
out = fopen("Timing1.plot", "we");
if (out == NULL) {
pw_log_error("Can't open Timing1.plot: %m");
} else {
@ -282,7 +282,7 @@ static void dump_scripts(struct data *d)
fclose(out);
}
out = fopen("Timing2.plot", "w");
out = fopen("Timing2.plot", "we");
if (out == NULL) {
pw_log_error("Can't open Timing2.plot: %m");
} else {
@ -298,7 +298,7 @@ static void dump_scripts(struct data *d)
fclose(out);
}
out = fopen("Timing3.plot", "w");
out = fopen("Timing3.plot", "we");
if (out == NULL) {
pw_log_error("Can't open Timing3.plot: %m");
} else {
@ -328,7 +328,7 @@ static void dump_scripts(struct data *d)
fclose(out);
}
out = fopen("Timing4.plot", "w");
out = fopen("Timing4.plot", "we");
if (out == NULL) {
pw_log_error("Can't open Timing4.plot: %m");
} else {
@ -355,7 +355,7 @@ static void dump_scripts(struct data *d)
fclose(out);
}
out = fopen("Timing5.plot", "w");
out = fopen("Timing5.plot", "we");
if (out == NULL) {
pw_log_error("Can't open Timing5.plot: %m");
} else {
@ -381,7 +381,7 @@ static void dump_scripts(struct data *d)
"unset output\n");
fclose(out);
}
out = fopen("Timings.html", "w");
out = fopen("Timings.html", "we");
if (out == NULL) {
pw_log_error("Can't open Timings.html: %m");
} else {
@ -409,7 +409,7 @@ static void dump_scripts(struct data *d)
fclose(out);
}
out = fopen("generate_timings.sh", "w");
out = fopen("generate_timings.sh", "we");
if (out == NULL) {
pw_log_error("Can't open generate_timings.sh: %m");
} else {
@ -624,7 +624,7 @@ int main(int argc, char *argv[])
data.filename = opt_output;
data.output = fopen(data.filename, "w");
data.output = fopen(data.filename, "we");
if (data.output == NULL) {
fprintf(stderr, "Can't open file %s: %m\n", data.filename);
return -1;