[Previous]
[Contents]
[Next]

dev_ischars()

determine the number of bytes available to be read from a terminal device

Synopsis:

#include <sys/dev.h>
int dev_ischars( int fd );

Description:

The dev_ischars() function returns the number of bytes available to be read from the terminal device associated with the file descriptor fd.

Returns:

The number of characters available. If an error occurs, -1 is returned and errno is set.

Errors:

EBADF
The fd argument is invalid.
ENOSYS
This function is not supported for this file descriptor.

Examples:

#include <sys/dev.h>
#include <stdio.h>

int main( void )
  {
    long n = 0;
    unsigned mode;

    mode = dev_mode( 0, 0, _DEV_MODES );
    /*
     * Busy-wait until data is entered
     */
    while( dev_ischars( 0 ) == 0 )
      printf( "%6ld\x0d", n++ );
    dev_mode( 0, mode, _DEV_MODES );
    return( EXIT_SUCCESS );
  }

Classification:

QNX

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

See also:

dev_arm(), dev_state(), errno


[Previous]
[Contents]
[Next]