query a file descriptor
#include <sys/fd.h> int qnx_fd_query( pid_t proc_pid, pid, int fd, struct _fd_entry *buf );
The qnx_fd_query() function returns an entry from the file descriptor table for process pid's file descriptor fd on the node indicated by proc_pid. If proc_pid and pid are zero, the current process is used. If just proc_pid is zero, the current node is used. To query another node, proc_pid should be passed as a virtual circuit to the process manager on that node. For example,
/* Attach a vc to the process manager on node 4 */ proc_pid = qnx_vc_attach( 4, PROC_PID, 0, 0 );
The fd is a small positive integer. If you ask for information on an fd that isn't in use, information is returned on the next monotonically greater fd. This automatic search for the next existing fd provides a convenient method of obtaining information on all handlers.
A file descriptor on success. If no file descriptor greater than or equal to fd exists, -1 is returned and errno is set.
#include <stdio.h> #include <sys/fd.h> #include <errno.h> void main() { int fd; struct _fd_entry buf; printf( "File descriptors for this process:\n" ); for( fd = 0; ( fd = qnx_fd_query( 0, 0, fd, &buf ) ) != -1; ++fd ) printf( "Fd %d Server pid %d\n", fd, buf.pid ); }
QNX
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes, but modifies errno |
Thread | Yes |
errno, qnx_fd_attach(), qnx_fd_detach(), qnx_vc_attach()