I was going through a serial program and I observed that they use select()
before using read()
. Why exactly is this required. Why cant we just dire
Programs that want to continue running while also reading interactive user input1 need to be multithreaded or they need to read input streams carefully and, specifically, conditionally.
Select(2) can be used to implement the second design pattern. It can determine whether input can be read without blocking the entire application.
1. Or some other input that arrives unpredictably.