qgetfd(3G)
qgetfd - get the read file descriptor associated with the event queue
As shipped in IRIX 6.5.22. Unchanged since IRIX 6.5.
NAME qgetfd - get the read file descriptor associated with the event queue C SPECIFICATION long qgetfd(void) PARAMETERS none FUNCTION RETURN VALUE The returned function value is the read file descriptor associated with the event queue. If there is an error, the returned value is a negative integer whose absolute value is an error value defined in <errno.h>. DESCRIPTION qgetfd returns the read file descriptor associated with the event queue. The file descriptor can then be used with the select(2) system call. EXAMPLE The following example (presented in pseudo-code; not to be typed verbatim) is suggested for reading events off of the GL queue using select(2): FD_ZERO(&readfds); if ((glfd = qgetfd()) < 0) { printf("bad file descriptor %d0, glfd); exit(-1); } for (;;) { while (qtest()) { . . blkqread() . . } /* Make sure all GL rendering which may be acting as a prompt or * cue for the user has completed before checking for a response * from the user. */ gflush(); FD_SET(glfd,&readfds); /* select with qgetfd descriptor */ FD_SET(,); /* select with others descriptors */ . nfound = select (,&readfds,,,); if (FD_ISSET(glfd,&readfds)) /* process queue events */ continue; if (FD_ISSET(,)) { /* process other then queue events */ . . } } The example provides two important pieces of advice. First, use blkqread instead of multiple qreads because it is more efficient. Second, to ensure the proper behavior of select, call qtest before and after you call select. When select indicates data is available on the file descriptor, there may not be GL event data to read. Similarly, there is a condition where select would block, but data is available. The use of qtest before and after select guards against this. SEE ALSO qread, gflush, select(2) (in the Programmer's Reference Manual) NOTES This routine is available only in immediate mode. BUGS The file descriptor returned by qgetfd will not be detected as ready for reading by the system call select(2) when TIMER events are inserted into the queue. Instead, one should use the timeout feature of select(2) to achieve the same functionality.