summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/input/input.c17
-rw-r--r--mpvcore/player/command.c4
-rw-r--r--mpvcore/player/configfiles.c9
3 files changed, 18 insertions, 12 deletions
diff --git a/mpvcore/input/input.c b/mpvcore/input/input.c
index 3e0313976a..744d474919 100644
--- a/mpvcore/input/input.c
+++ b/mpvcore/input/input.c
@@ -2309,12 +2309,17 @@ struct input_ctx *mp_input_init(struct mpv_global *global)
}
#ifndef __MINGW32__
- long ret = pipe(ictx->wakeup_pipe);
- for (int i = 0; i < 2 && ret >= 0; i++) {
- ret = fcntl(ictx->wakeup_pipe[i], F_GETFL);
- if (ret < 0)
- break;
- ret = fcntl(ictx->wakeup_pipe[i], F_SETFL, ret | O_NONBLOCK);
+ int ret = pipe(ictx->wakeup_pipe);
+ if (ret == 0) {
+ for (int i = 0; i < 2 && ret >= 0; i++) {
+ mp_set_cloexec(ictx->wakeup_pipe[i]);
+ ret = fcntl(ictx->wakeup_pipe[i], F_GETFL);
+ if (ret < 0)
+ break;
+ ret = fcntl(ictx->wakeup_pipe[i], F_SETFL, ret | O_NONBLOCK);
+ if (ret < 0)
+ break;
+ }
}
if (ret < 0)
MP_ERR(ictx, "Failed to initialize wakeup pipe: %s\n", strerror(errno));
diff --git a/mpvcore/player/command.c b/mpvcore/player/command.c
index d8a317413f..129c0aa58a 100644
--- a/mpvcore/player/command.c
+++ b/mpvcore/player/command.c
@@ -65,6 +65,8 @@
#include <sys/mman.h>
#endif
+#include "osdep/io.h"
+
#include "mp_core.h"
#include "mp_lua.h"
@@ -2334,7 +2336,7 @@ static int overlay_add(struct MPContext *mpctx, int id, int x, int y,
fd = -1;
close_fd = false;
} else {
- fd = open(file, O_RDONLY | O_BINARY);
+ fd = open(file, O_RDONLY | O_BINARY | O_CLOEXEC);
}
void *p = mmap(NULL, h * stride, PROT_READ, MAP_SHARED, fd, offset);
if (fd >= 0 && close_fd)
diff --git a/mpvcore/player/configfiles.c b/mpvcore/player/configfiles.c
index 29350c0aed..31e3d0e75d 100644
--- a/mpvcore/player/configfiles.c
+++ b/mpvcore/player/configfiles.c
@@ -51,7 +51,6 @@ bool mp_parse_cfgfiles(struct MPContext *mpctx)
struct MPOpts *opts = mpctx->opts;
m_config_t *conf = mpctx->mconfig;
char *conffile;
- int conffile_fd;
if (!opts->load_config)
return true;
if (!m_config_parse_config_file(conf, MPLAYER_CONFDIR "/mpv.conf", 0) < 0)
@@ -60,11 +59,11 @@ bool mp_parse_cfgfiles(struct MPContext *mpctx)
if ((conffile = mp_find_user_config_file("config")) == NULL)
MP_ERR(mpctx, "mp_find_user_config_file(\"config\") problem\n");
else {
- if ((conffile_fd = open(conffile, O_CREAT | O_EXCL | O_WRONLY,
- 0666)) != -1) {
+ int fd = open(conffile, O_CREAT | O_EXCL | O_WRONLY | O_CLOEXEC, 0666);
+ if (fd != -1) {
MP_INFO(mpctx, "Creating config file: %s\n", conffile);
- write(conffile_fd, DEF_CONFIG, sizeof(DEF_CONFIG) - 1);
- close(conffile_fd);
+ write(fd, DEF_CONFIG, sizeof(DEF_CONFIG) - 1);
+ close(fd);
}
if (m_config_parse_config_file(conf, conffile, 0) < 0)
return false;