summaryrefslogtreecommitdiff
path: root/ghc/lib/misc/cbits/createSocket.c
diff options
context:
space:
mode:
Diffstat (limited to 'ghc/lib/misc/cbits/createSocket.c')
-rw-r--r--ghc/lib/misc/cbits/createSocket.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ghc/lib/misc/cbits/createSocket.c b/ghc/lib/misc/cbits/createSocket.c
index 8b30d7278f..297fcb21b5 100644
--- a/ghc/lib/misc/cbits/createSocket.c
+++ b/ghc/lib/misc/cbits/createSocket.c
@@ -16,6 +16,7 @@ StgInt
createSocket(I_ family, I_ type, I_ protocol)
{
int fd;
+ long flags;
if ((fd = socket((int)family, (int)type, (int)protocol)) < 0) {
if (errno != EINTR) {
@@ -48,5 +49,10 @@ createSocket(I_ family, I_ type, I_ protocol)
return (StgInt)-1;
}
}
+
+ /* set the non-blocking flag on this file descriptor */
+ flags = fcntl(fd, F_GETFL);
+ fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+
return (StgInt)fd;
}