Make sure exclusive mode is turned off on exit.
This commit is contained in:
parent
6e65d1e731
commit
03cc4cd88f
@ -165,6 +165,7 @@ int serial_init(const char* port, unsigned long baud)
|
|||||||
}
|
}
|
||||||
|
|
||||||
signal(SIGINT, sigint_handler);
|
signal(SIGINT, sigint_handler);
|
||||||
|
atexit(serial_done);
|
||||||
|
|
||||||
/* set the terminal to exclusive mode */
|
/* set the terminal to exclusive mode */
|
||||||
if (ioctl(hSerial, TIOCEXCL) != 0) {
|
if (ioctl(hSerial, TIOCEXCL) != 0) {
|
||||||
@ -280,6 +281,7 @@ int serial_baud(unsigned long baud)
|
|||||||
void serial_done(void)
|
void serial_done(void)
|
||||||
{
|
{
|
||||||
if (hSerial != -1) {
|
if (hSerial != -1) {
|
||||||
|
ioctl(hSerial, TIOCNXCL);
|
||||||
tcflush(hSerial, TCIOFLUSH);
|
tcflush(hSerial, TCIOFLUSH);
|
||||||
tcsetattr(hSerial, TCSANOW, &old_sparm);
|
tcsetattr(hSerial, TCSANOW, &old_sparm);
|
||||||
ioctl(hSerial, TIOCNXCL);
|
ioctl(hSerial, TIOCNXCL);
|
||||||
|
Loading…
Reference in New Issue
Block a user