From 630b4cac33127c56d9dd46289b584a28b95ed6d0 Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Wed, 13 May 2015 09:15:25 +0200 Subject: [PATCH] recv.2, send.2: Explain some subtleties of MSG_DONTWAIT versus O_NONBLOCK Signed-off-by: Michael Kerrisk --- man2/recv.2 | 17 +++++++++++++---- man2/send.2 | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/man2/recv.2 b/man2/recv.2 index a3470cf11..92900976d 100644 --- a/man2/recv.2 +++ b/man2/recv.2 @@ -109,12 +109,21 @@ flag of .BR MSG_DONTWAIT " (since Linux 2.2)" Enables nonblocking operation; if the operation would block, the call fails with the error -.BR EAGAIN " or " EWOULDBLOCK -(this can also be enabled using the +.BR EAGAIN " or " EWOULDBLOCK . +This provides similar behavior to setting the .B O_NONBLOCK -flag with the +flag (via the +.BR fcntl (2) .B F_SETFL -.BR fcntl (2)). +operation), but differs in that +.B MSG_DONTWAIT +is a per-call option, whereas +.B O_NONBLOCK +is a setting on the open file description (see +.BR open (2)), +which will affect all threads in the calling process +and as well as other processes that hold file descriptors +referring to the same open file description. .TP .BR MSG_ERRQUEUE " (since Linux 2.2)" This flag diff --git a/man2/send.2 b/man2/send.2 index 6eb7c4acc..9307eb9be 100644 --- a/man2/send.2 +++ b/man2/send.2 @@ -191,11 +191,21 @@ Enables nonblocking operation; if the operation would block, .B EAGAIN or .B EWOULDBLOCK -is returned (this can also be enabled using the +is returned. +This provides similar behavior to setting the .B O_NONBLOCK -flag with the +flag (via the +.BR fcntl (2) .B F_SETFL -.BR fcntl (2)). +operation), but differs in that +.B MSG_DONTWAIT +is a per-call option, whereas +.B O_NONBLOCK +is a setting on the open file description (see +.BR open (2)), +which will affect all threads in the calling process +and as well as other processes that hold file descriptors +referring to the same open file description. .TP .BR MSG_EOR " (since Linux 2.2)" Terminates a record (when this notion is supported, as for sockets of type