Solaris 10 /dev/poll bug
807557Mar 8 2006 — edited Jul 5 2006Solaris 10, at least on my T2000, seems to give me an EINVAL from the DP_POLL ioctl in a case where it shouldn't. The below example code should clarify:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
#include <sys/resource.h>
#include <sys/devpoll.h>
/*
This program demonstrates what seems to be a bug in the /dev/poll interface
on Solaris 10 on our T2000. The man page says:
EINVAL The request or arg parameter is not valid
for this device, or field of the dvpoll
struct pointed by arg is not valid (for
example, dp_nfds is greater than
{OPEN_MAX}).
But in this case, we get EINVAL even though dp_nfds is not greater than
OPEN_MAX.
*/
void fatal(const char *f)
{
fprintf(stderr, "Unable to show problem: %s\n", f);
exit(1);
}
int main(void)
{
struct rlimit r;
struct pollfd pfd[256];
struct dvpoll dp;
int i;
if(getrlimit(RLIMIT_NOFILE, &r)!=0) fatal("unable to get file limit");
if(r.rlim_cur!=256) fatal("set fd limit to 256");
if(OPEN_MAX!=256) fatal("OPEN_MAX must be 256");
i=open("/dev/poll", O_RDWR);
if(i<0) fatal("unable to open /dev/poll");
dp.dp_timeout=0;
dp.dp_nfds=256; /* Changing this to 255 fixes the problem */
dp.dp_fds=pfd;
if(ioctl(i, DP_POLL, &dp)==0) fatal("it does not appear on this system");
printf("errno=%d - Why?\n", errno);
}
Any ideas?