From 35c3c29cc40ab7f74a6789518eb7bd13cf7bc0d4 Mon Sep 17 00:00:00 2001 From: Martin Hebnes Pedersen Date: Thu, 17 Mar 2016 09:46:48 +0100 Subject: [PATCH 1/2] Fix kissattach 'Device or resource busy' Sometimes kissattach had an issue using the pseudo terminal on some versions of Linux: 'Error setting line discipline: TIOCSETD: Device or resource busy'. This fix resolves the issue by not reading from the pty's master fd, until kissattach has opened and configured the slave. This is implemented using select() to wait for data before reading from the master fd. --- kiss.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/kiss.c b/kiss.c index db68d69..a68a1c1 100644 --- a/kiss.c +++ b/kiss.c @@ -884,12 +884,23 @@ static int kiss_get (/* MYFDTYPE fd*/ void ) #else /* Linux/Cygwin version */ int n = 0; + fd_set fd_in; + int rc; while ( n == 0 ) { + /* Reading from master fd of the pty before the client has connected leads to trouble with kissattach. */ + /* Use select to check if the slave has sent any data before trying to read from it. */ + FD_ZERO(&fd_in); + rc = select(pt_master_fd + 1, &fd_in, NULL, &fd_in, NULL); - n = read(pt_master_fd, &ch, (size_t)1); + if (rc == 0) + { + continue; + } - if (n != 1) { + if (rc == MYFDERROR + || (n = read(pt_master_fd, &ch, (size_t)1)) != 1) + { text_color_set(DW_COLOR_ERROR); dw_printf ("\nError receiving kiss message from client application. Closing %s.\n\n", pt_slave_name); From 5920ecda5152b892237a07cf1e14aa0b91e91b69 Mon Sep 17 00:00:00 2001 From: Martin Hebnes Pedersen Date: Thu, 17 Mar 2016 09:47:52 +0100 Subject: [PATCH 2/2] Remove kissattach 'known problem' print --- kiss.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/kiss.c b/kiss.c index a68a1c1..f9933ba 100644 --- a/kiss.c +++ b/kiss.c @@ -906,14 +906,6 @@ static int kiss_get (/* MYFDTYPE fd*/ void ) dw_printf ("\nError receiving kiss message from client application. Closing %s.\n\n", pt_slave_name); perror (""); - /* Message added between 1.1 beta test and final version 1.1 */ - - /* TODO: Determine root cause and find proper solution. */ - - dw_printf ("This is a known problem that sometimes shows up when using with kissattach.\n"); - dw_printf ("There are a couple work-arounds described in the Dire Wolf User Guide\n"); - dw_printf ("and the Raspberry Pi APRS documents.\n"); - close (pt_master_fd); pt_master_fd = MYFDERROR;