source->base.interface = &timer_source_interface;
source->base.loop = loop;
- source->fd = timerfd_create(CLOCK_MONOTONIC, 0);
+ source->fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
if (source->fd < 0) {
fprintf(stderr, "could not create timerfd\n: %m");
free(source);
sigemptyset(&mask);
sigaddset(&mask, signal_number);
- source->fd = signalfd(-1, &mask, 0);
+ source->fd = signalfd(-1, &mask, SFD_CLOEXEC);
if (source->fd < 0) {
fprintf(stderr, "could not create fd to watch signal\n: %m");
free(source);
if (loop == NULL)
return NULL;
- loop->epoll_fd = epoll_create(16);
+ loop->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
if (loop->epoll_fd < 0) {
free(loop);
return NULL;
#include <sys/un.h>
#include <ctype.h>
#include <assert.h>
+#include <fcntl.h>
#include <sys/poll.h>
#include "wayland-client-protocol.h"
const char *runtime_dir;
size_t name_size;
- display->fd = socket(PF_LOCAL, SOCK_STREAM, 0);
+ display->fd = socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (display->fd < 0)
return -1;
* OF THIS SOFTWARE.
*/
+#define _GNU_SOURCE
+
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
#include <dlfcn.h>
#include <assert.h>
#include <sys/time.h>
+#include <fcntl.h>
#include <ffi.h>
#include "wayland-server.h"
int client_fd;
length = sizeof name;
- client_fd = accept (fd, (struct sockaddr *) &name, &length);
+ client_fd =
+ accept4(fd, (struct sockaddr *) &name, &length, SOCK_CLOEXEC);
if (client_fd < 0)
fprintf(stderr, "failed to accept\n");
if (s == NULL)
return -1;
- s->fd = socket(PF_LOCAL, SOCK_STREAM, 0);
+ s->fd = socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (s->fd < 0) {
free(s);
return -1;