summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2014-12-21 01:11:18 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2014-12-21 01:11:18 +0000
commit4557dacfbe04206c57e459b734016d2b6edfe7f3 (patch)
tree8275bbbbb77095c079bd9e94e00ac91129d3d481 /src
parent23bdcb4ad4ef19d99b729e5282fd15df6300a3b5 (diff)
downloadskalibs-4557dacfbe04206c57e459b734016d2b6edfe7f3.tar.xz
Stricter trynbwaitall to actually catch the problems
Diffstat (limited to 'src')
-rw-r--r--src/sysdeps/trynbwaitall.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/sysdeps/trynbwaitall.c b/src/sysdeps/trynbwaitall.c
index 0f55080..ae79f1c 100644
--- a/src/sysdeps/trynbwaitall.c
+++ b/src/sysdeps/trynbwaitall.c
@@ -27,6 +27,11 @@
#define MSG_NOSIGNAL 0
#endif
+#ifndef MSG_DONTWAIT
+#define MSG_DONTWAIT 0
+#endif
+
+
static int ndelay_on (int fd)
{
register int got = fcntl(fd, F_GETFL) ;
@@ -35,8 +40,8 @@ static int ndelay_on (int fd)
static int child (int p, int fd)
{
- char c ;
- struct iovec v = { .iov_base = &c, .iov_len = 1 } ;
+ char buf[8] ;
+ struct iovec v = { .iov_base = buf, .iov_len = 8 } ;
struct msghdr msg =
{
.msg_name = 0,
@@ -56,7 +61,7 @@ static int child (int p, int fd)
/* The following recvmsg may block, despite setting the fd
non-blocking. That is what we're testing. */
- if (recvmsg(fd, &msg, MSG_WAITALL) < 1) return 111 ;
+ if (recvmsg(fd, &msg, MSG_WAITALL | MSG_DONTWAIT) < 1) return 111 ;
if (write(p, "", 1) < 1) return 111 ;
return 0 ;
}