I looked on the Linux man pages for the answer but can't seem to find it. I know that read()
is blocking but I'm still not sure about write()
.
Can anyone point me to any documentation for clarification?
No, it only blocks the process until the content of the buffer is copied to kernel space.
Note: The default mode is blocking. If data is not available to the socket, and the socket is in blocking and synchronous modes, the READ call blocks the caller until data arrives.
The write() method writes a specified text to the file. Where the specified text will be inserted depends on the file mode and stream position. "a" : The text will be inserted at the current file stream position, default at the end of the file.
Non-blocking writes eliminate such blocking by buffering the written data elsewhere in memory and unblocking the writing process immediately. Subsequent reads to the updated page locations are also made non-blocking.
Read POSIX on read()
and
write()
. See also functions such as open()
and pipe()
.
It depends on the attributes of the file descriptor you're reading from or writing to (think O_NONBLOCK
, for example), and on the underlying file type (disk file vs pipe vs FIFO vs socket vs character or block special), and so on.
Succinctly, both read()
and write()
can be blocking or non-blocking, depending on circumstances.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With