Make sure exclusive mode is turned off on exit.

This commit is contained in:
David Betz 2015-03-08 21:21:05 -04:00
parent 6e65d1e731
commit 03cc4cd88f
1 changed files with 2 additions and 0 deletions

View File

@ -165,6 +165,7 @@ int serial_init(const char* port, unsigned long baud)
}
signal(SIGINT, sigint_handler);
atexit(serial_done);
/* set the terminal to exclusive mode */
if (ioctl(hSerial, TIOCEXCL) != 0) {
@ -280,6 +281,7 @@ int serial_baud(unsigned long baud)
void serial_done(void)
{
if (hSerial != -1) {
ioctl(hSerial, TIOCNXCL);
tcflush(hSerial, TCIOFLUSH);
tcsetattr(hSerial, TCSANOW, &old_sparm);
ioctl(hSerial, TIOCNXCL);