Skip to content

Fix kissattach 'Device or resource busy' #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 26, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
martinhpedersen committed Mar 17, 2016
commit 35c3c29cc40ab7f74a6789518eb7bd13cf7bc0d4
15 changes: 13 additions & 2 deletions kiss.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down