util/chpty.cc
/// Check if there is data to be read on the controlling file descriptor.
/// waiting up to the read timeout period for some data to arrive.
/// It will ignore signals that may interrupt the wait.
/// Return 0 if no data ready (or pty closed), nonzero otherwise.
///
/// *  May throw Chpty_read_exception
///
Check if there is data to be read on the controlling file descriptor.
waiting up to the read timeout period for some data to arrive.
It will ignore signals that may interrupt the wait.
Return 0 if no data ready (or pty closed), nonzero otherwise.


Check if there is data to be read on the controlling file descriptor . waiting up to the read timeout period for some data to arrive . It will ignore signals that may interrupt the wait . Return 0 if no data ready ( or pty closed ) nonzero otherwise .
int Pty_controller::can_read()
{
    if (non_fd == m_cfd) {
        return 0;
    }
    struct timeval tv = m_rtimeout;
    while (1) {
        fd_set fds;
        FD_ZERO(&fds);
        FD_SET( m_cfd, &fds);
        errno = 0;
        int rc = select( m_cfd+1, &fds, NULL, NULL, &tv );
        if (0 < rc) {
            return FD_ISSET( m_cfd, &fds );
        }
        else if (0 == rc) {  
            return 0;
        }
        else  if (libc_err == rc) {
            if (errno != EINTR) {
                throw Chpty_read_exception();
            }
        }
        LOG_DEBUG(Lgr) << "Pty_controller::can_read() select timeout interrupted.";
    }
}
int Pty_controller :: can_read ( ) { if ( non_fd == m_cfd ) { return 0 ; } struct timeval tv = m_rtimeout ; while ( 1 ) { fd_set fds ; FD_ZERO ( & fds ) ; FD_SET ( m_cfd , & fds ) ; errno = 0 ; int rc = select ( m_cfd + 1 , & fds , NULL , NULL , & tv ) ; if ( 0 < rc ) { return FD_ISSET ( m_cfd , & fds ) ; } else if ( 0 == rc ) { return 0 ; } else if ( libc_err == rc ) { if ( errno != EINTR ) { throw Chpty_read_exception ( ) ; } } LOG_DEBUG ( Lgr ) << " " ; } }
Check if there is data to be read on the controlling file descriptor.
Check if there is data to be read on the controlling file descriptor .
//                        RD    WR    XC    time remaining // timeout occurred