I am implementing a client which uses two threads: one that receives data from a server and prints it to stdout, the other one uses fgets to ask a string to the user and sends a message to the server.The threads are always in execution, but there is a problem: I don’t know how to stop the thread that takes input from the user.I tried closing stdin with fclose, but the stream remains opened until the user digits a string.How is possible to close the input buffer in a way that fgets is interrupted?
I hope the question is clear.
I am implementing a client which uses two threads: one that receives data from
Share
A signal can interrupt an I/O operation. Assuming you didn’t use the SA_RESTART flag for the sigaction signal handler, the read will return with an errno of EINTR.