return information about the terminal device associated with a file
#include <sys/dev.h> int dev_info( int fd, struct _dev_info_entry *info );
The dev_info() function returns information about the terminal device associated with the file descriptor given in fd.
If the call is successful, the structure pointed to by info contains data in the following members:
The (nid, tty) pair uniquely identifies the terminal device that is associated with fd. As shown in the example, these values can be used to build a pathname for this device.
The symbolic name given in driver_type() is intended to allow applications to identify the type of device that is being referred to by fd. Examples of currently defined strings for driver_type() are:
The (nid, driver_pid) pair can be used to identify the process that controls a particular device. Device-dependent control messages can often be sent to these driver processes to alter the behavior of that particular device.
Zero on success. The structure pointed to by info contains information about the file descriptor fd. A return of -1 indicates failure, in which case the global variable errno is set, and the info structure is not filled.
#include <sys/dev.h> #include <stdio.h> int main( void ) { struct _dev_info_entry info; if( dev_info( 0, &info ) == 0 ) { printf( "NODE %d,TTY %d\n", info.nid, info.tty ); printf( "also known as: %s\n", &info.tty_name[0] ); printf( "is a %s device\n", &info.driver_type[0] ); } return( EXIT_SUCCESS ); }
QNX
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes, but modifies errno |
Thread | Yes |