I'm using termios.h to communicate with a USB Dongle. I would like to close the file descriptor when I disconnect the dongle. Is there a way to do this. I know that for f.e. a TCP/IP connection you get a EOF if the other party closes the connection. However, with a serial connection, my program basically runs wild (I'm using a loop to read from the descriptor...).
Basically I would like to have some indication that the connection was closed so that i can gracefully shut down the program. Maybe by changing the settings with ioctl?