When you read from a file, the data is already there, so why would scanf()
wait? Or any other way of reading the file?
/dev/pts/<i>N</i>
are Unix 98 pseudoterminals, which by their very nature are interactive. A blocking read from one waits for interactive input. A nonblocking read would just tell you that there is no data to read right now.
If you create a pipe between processes, associate the read end with an stdio
FILE
handle via fdopen()
, you can use scanf()
to scan data from the pipe. That, too, will wait for input, unless all write ends of the pipe are closed (then the scanf
will fail with end-of-input). So, there is nothing special about the pseudoterminals in this respect.