VSI C x86-64 V7.5-009 (GEM 50XBR) on OpenVMS x86_64 V9.2-2
Code: Select all
#include <unistd.h>
#include <stdio.h>
#include <poll.h>
#include <string.h>
#include <errno.h>
int main(int argc, char **argv)
{
int i,inlen, sts;
struct pollfd poll_fds[4];
nfds_t poll_nfds;
char buff[4096]={0};
poll_fds[0].fd=fileno(stdin);
poll_fds[0].events=POLLIN;
poll_nfds=1;
sts=poll(poll_fds,poll_nfds,10000);
if(sts<0)
{
printf("ppoll: %.100s, errno=%d\n", strerror(errno), errno);
}
for(i=0; i<poll_nfds;i++)
{
if((poll_fds[i].revents & POLLIN) !=0 )
{
inlen=read(poll_fds[i].fd,buff,sizeof(buff));
printf("read[%d]: %.60s\n",inlen, buff);
}
}
printf("sts=%d revents=%08x\n",sts, poll_fds[0].revents);
}
$ ./t.exe
en
read[3]: en
sts=1 revents=00000001
vms>
$ run test_poll
ppoll: i/o error, errno=5
sts=-1 revents=00000000