简体   繁体   English

C语言中的write()函数是阻塞还是非阻塞?

[英]Is the write() function in C blocking or non-blocking?

I looked on the Linux man pages for the answer but can't seem to find it. 我在Linux手册页上寻找了答案,但似乎找不到。 I know that read() is blocking but I'm still not sure about write() . 我知道read()会阻塞,但是我仍然不确定write() Can anyone point me to any documentation for clarification? 谁能指出我要澄清的任何文档?

Read POSIX on read() and write() . read()write()read() POSIX。 See also functions such as open() and pipe() . 另请参见open()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. 它取决于您正在读取或写入的文件描述符的属性(例如,考虑O_NONBLOCK ),以及底层文件类型(磁盘文件,管道,FIFO,FIFO,套接字,字符或特殊块)等等。 。

Succinctly, both read() and write() can be blocking or non-blocking, depending on circumstances. 简而言之,根据情况, read()write()都可以是阻塞的或非阻塞的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM