citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit 44b27072c817b3c589abe528f5d41319679a6d64
parent c7098cf3fce676880e87d1cb1632496747c22702
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Thu, 17 Mar 2016 22:40:27 -0600

viewer: apple doesn't have socket(..., | SOCK_NONBLOCK, ...)

Diffstat:
Mviewer/af_unix.cxx | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/viewer/af_unix.cxx b/viewer/af_unix.cxx @@ -21,8 +21,21 @@ af_unix::af_unix(int f) : void af_unix::set_listen() { +#ifdef __APPLE__ + // OS X socket() doesn't take SOCK_NONBLOCK + if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) + err(1, "socket"); + + int flags = fcntl(fd, F_GETFL, 0); + if (flags < 0) + err(1, "fcntl(F_GETFL)"); + fcntl(fd, F_SETFL, flags & O_NONBLOCK); + if (flags < 0) + err(1, "fcntl(F_SETFL)"); +#else if ((fd = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0)) == -1) err(1, "socket"); +#endif struct sockaddr_un addr; memset(&addr, 0, sizeof(addr));