summary refs log tree commit diff
path: root/host/start-vm/unix.c
diff options
context:
space:
mode:
Diffstat (limited to 'host/start-vm/unix.c')
-rw-r--r--host/start-vm/unix.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/host/start-vm/unix.c b/host/start-vm/unix.c
new file mode 100644
index 0000000..43143fd
--- /dev/null
+++ b/host/start-vm/unix.c
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: EUPL-1.2+
+// SPDX-FileCopyrightText: 2023 Alyssa Ross <hi@alyssa.is>
+
+#include <fcntl.h>
+
+[[gnu::fd_arg(1)]]
+int clear_cloexec(int fd)
+{
+	int flags = fcntl(fd, F_GETFD);
+	if (flags == -1)
+		return -1;
+	return fcntl(fd, F_SETFD, flags & ~FD_CLOEXEC);
+}