return information about a terminal device


#include <sys/dev.h>
int dev_fdinfo( pid_t server,
                pid_t pid,
                int fd,
                struct _dev_info_entry *info );


The dev_fdinfo() function returns information about the terminal device that is controlled by the given server process, and that is associated with file descriptor fd belonging to process pid.

If the call is successful, the structure pointed to by info contains the same information as that returned by the dev_info() call. In general, you'll want to use dev_info() to get information on your own file descriptors, however dev_fdinfo() provides a mechanism of querying the status of all devices that are opened by a given device driver process.


Zero on success. The structure pointed to by info contains information about the file descriptor fd belonging to the process pid. A return of -1 indicates failure, in which case the global variable errno is set, and the info structure isn't filled.


The dev_fdinfo() function isn't supported for this fd.
The fd argument is invalid.
The server pid doesn't exist.


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

 * Display information about a file
 * that is opened to the driver 'server'
 * by 'pid' with handle 'fd'

int main( int argc, char *argv[] )
    pid_t server, pid;
    int fd;
    struct _dev_info_entry info;

    server = atoi( argv[1] );
    pid = atoi( argv[2] );
    fd = atoi( argv[3] );

    if( dev_fdinfo( server, pid, fd, &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] );
    } else {
      printf( "Unable to obtain information\n" );
    return( EXIT_SUCCESS );



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

See also:

dev_info(), errno, open()