aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/oslib-posix.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index d55af69..827a7aa 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -253,6 +253,25 @@ void qemu_set_cloexec(int fd)
assert(f != -1);
}
+int qemu_socketpair(int domain, int type, int protocol, int sv[2])
+{
+ int ret;
+
+#ifdef SOCK_CLOEXEC
+ ret = socketpair(domain, type | SOCK_CLOEXEC, protocol, sv);
+ if (ret != -1 || errno != EINVAL) {
+ return ret;
+ }
+#endif
+ ret = socketpair(domain, type, protocol, sv);;
+ if (ret == 0) {
+ qemu_set_cloexec(sv[0]);
+ qemu_set_cloexec(sv[1]);
+ }
+
+ return ret;
+}
+
char *
qemu_get_local_state_dir(void)
{