I have a thread, that reads serial device (/dev/ttyUSB0), and writes data to stdout :
void io_thread_func () {
int serial_port = open(settings.port, O_RDWR);
while (1) {
char buf[100];
int n = read(serial_port, buf, 100);
fwrite(buf, 1, n, stdout);
}
}
How I can interrupt "read(...)" syscall from another thread ? Can I call "close(serial_port)" from another thread to interrupt all I/O blocking functions ? (I need to interrupt I/O blocking functions to close the thread correctly)