编辑:我做了一些研究,发现只是直接通过syscall调用read不会更改任何内容。内核代码似乎进行了一些同步处理,但是我不太了解(read_write.c)
最佳答案
这是未定义的行为POSIX
说:
The read() function shall attempt to read nbyte bytes from the file associated with the open file descriptor, fildes, into the buffer pointed to by buf. The behavior of multiple concurrent reads on the same pipe, FIFO, or terminal device is unspecified.
关于multithreading - 从两个线程同时读取文件描述符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5057737/