#ifdef CONFIG_PIPE2
ret = pipe2(pipefd, O_CLOEXEC);
-#else
+ if (ret != -1 || errno != ENOSYS) {
+ return ret;
+ }
+#endif
ret = pipe(pipefd);
if (ret == 0) {
qemu_set_cloexec(pipefd[0]);
qemu_set_cloexec(pipefd[1]);
}
-#endif
return ret;
}
#ifdef SOCK_CLOEXEC
ret = socket(domain, type | SOCK_CLOEXEC, protocol);
-#else
+ if (ret != -1 || errno != EINVAL) {
+ return ret;
+ }
+#endif
ret = socket(domain, type, protocol);
if (ret >= 0) {
qemu_set_cloexec(ret);
}
-#endif
return ret;
}
#ifdef CONFIG_ACCEPT4
ret = accept4(s, addr, addrlen, SOCK_CLOEXEC);
-#else
+ if (ret != -1 || errno != EINVAL) {
+ return ret;
+ }
+#endif
ret = accept(s, addr, addrlen);
if (ret >= 0) {
qemu_set_cloexec(ret);
}
-#endif
return ret;
}