util/chpty.cc
/// Check if there is space for data to be written on the controlling
/// file descriptor, waiting up to the write timeout period for space
/// to become available.  Return 0 if not ready (or pty closed),
/// nonzero otherwise.
///
/// * May throw Chpty_write_exception
///
Check if there is space for data to be written on the controlling
file descriptor, waiting up to the write timeout period for space
to become available.  Return 0 if not ready (or pty closed),
nonzero otherwise.


Check if there is space for data to be written on the controlling file descriptor waiting up to the write timeout period for space to become available . Return 0 if not ready ( or pty closed ) nonzero otherwise .
int Pty_controller::can_write()
{
    if (non_fd == m_cfd) {
        return 0;
    }
    struct timeval tv = m_wtimeout;
    fd_set fds;
    FD_ZERO(&fds);
    FD_SET( m_cfd, &fds);
    int rc = select( m_cfd+1, NULL, &fds, NULL, &tv );
    if (libc_err == rc) {
        throw Chpty_write_exception();
    }
    if (0 == rc) {   
        return 0;
    }
    return FD_ISSET(m_cfd, &fds);
}
int Pty_controller :: can_write ( ) { if ( non_fd == m_cfd ) { return 0 ; } struct timeval tv = m_wtimeout ; fd_set fds ; FD_ZERO ( & fds ) ; FD_SET ( m_cfd , & fds ) ; int rc = select ( m_cfd + 1 , NULL , & fds , NULL , & tv ) ; if ( libc_err == rc ) { throw Chpty_write_exception ( ) ; } if ( 0 == rc ) { return 0 ; } return FD_ISSET ( m_cfd , & fds ) ; }
Check if there is space for data to be written on the controlling
file descriptor, waiting up to the write timeout period for space
to become available.
Check if there is space for data to be written on the controlling file descriptor waiting up to the write timeout period for space to become available .
//                        RD    WR    XC    timeout // timeout occurred