determine the number of bytes available to be read from a terminal device
#include <sys/dev.h> int dev_ischars( int fd );
The dev_ischars() function returns the number of bytes available to be read from the terminal device associated with the file descriptor fd.
The number of characters available. If an error occurs, -1 is returned and errno is set.
#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 ); }
QNX
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes, but modifies errno |
Thread | Yes |