treewide: make more file descriptors cloexec

Avoid file descriptor leakage into child processes by marking them `O_CLOEXEC`.
This commit is contained in:
Barnabás Pőcze 2025-10-28 20:03:13 +01:00 committed by Wim Taymans
parent 6ef23a1a9a
commit e5b741732d
9 changed files with 9 additions and 9 deletions

View file

@ -544,7 +544,7 @@ static int setup_socket(struct state *state)
struct ifreq req;
struct props *p = &state->props;
fd = socket(AF_PACKET, SOCK_DGRAM|SOCK_NONBLOCK, htons(ETH_P_TSN));
fd = socket(AF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, htons(ETH_P_TSN));
if (fd < 0) {
spa_log_error(state->log, "socket() failed: %m");
return -errno;

View file

@ -2613,7 +2613,7 @@ static int sco_create_socket(struct impl *backend, struct spa_bt_adapter *adapte
socklen_t len;
bdaddr_t src;
spa_autoclose int sock = socket(PF_BLUETOOTH, SOCK_SEQPACKET | SOCK_NONBLOCK, BTPROTO_SCO);
spa_autoclose int sock = socket(PF_BLUETOOTH, SOCK_SEQPACKET | SOCK_CLOEXEC | SOCK_NONBLOCK, BTPROTO_SCO);
if (sock < 0) {
spa_log_error(backend->log, "socket(SEQPACKET, SCO) %s", strerror(errno));
return -1;

View file

@ -756,7 +756,7 @@ static bool parse_clock_id(struct impl *this, const char *s)
static bool parse_clock_device(struct impl *this, const char *s)
{
int fd = open(s, O_RDONLY);
int fd = open(s, O_RDONLY | O_CLOEXEC);
if (fd == -1) {
spa_log_info(this->log, "failed to open clock device '%s': %m", s);
return false;

View file

@ -163,7 +163,7 @@ static VkShaderModule createShaderModule(struct vulkan_compute_state *s, const c
int fd;
struct stat stat;
if ((fd = open(shaderFile, 0, O_RDONLY)) == -1) {
if ((fd = open(shaderFile, 0, O_RDONLY | O_CLOEXEC)) == -1) {
spa_log_error(s->log, "can't open %s: %m", shaderFile);
return VK_NULL_HANDLE;
}