Skip to content

Commit

Permalink
pty.c: Close file descriptors in off-nominal branch of PTY master thr…
Browse files Browse the repository at this point in the history
…ead.

All paths in the PTY master thread close both file descriptors before
breaking, except one, which can result in a file descriptor leak of
one of the file descriptors when that branch is taken. This resulted
in a leak of 1 file descriptor per remote console open at shutdown.
While that case is not a meaningful leak, we now always close both
descriptors in all branches to prevent this leak from happening.

Resolves: #20
  • Loading branch information
InterLinked1 committed Jan 11, 2025
1 parent f234f3f commit 266a8c0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bbs/pty.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ static void *pty_master_fd(void *varg)
}
}
} else {
/* Something else happened that should effect a disconnect. */
bbs_debug(10, "Exceptional activity returned from poll: %s/%s\n", poll_revent_name(fds[0].revents), poll_revent_name(fds[1].revents));
close(fds[1].fd);
close(fds[0].fd);
break;
}
}
Expand Down

0 comments on commit 266a8c0

Please sign in to comment.