<div>Hello ,<br><br>
I am right now implementing test case for "select" API, and I have
right now come across a very typical problem. Might be I am knowing
less about select..or so.. <br>
<br>
My problem is that I have created two files as follows...<br>
<br>
system("touch tmp1;echo absjkhsk>tmp1;chmod 400 tmp1");<br>
system("touch tmp2;echo jhagsakjg>tmp2;chmod 200 tmp2");<br>
<br>
Now I opened the files as follows..<br>
<br>
fd1=open("tmp1",O_RDONLY);<br>
fd2=open("tmp2",O_WRONLY);<br>
<br>
Now I added both the file descriptors in "rfds" and "wfds" (Basically defined as "fd_set rfds,wfds; ") as follows...<br>
<br>
FD_SET(fd1,&rfds);<br>
n=n>fd1?n:fd1;<br>
FD_SET(fd2,&wfds);<br>
n=n>fd2?n:fd2;<br>
FD_SET(fd1,&wfds);<br>
n=n>fd1?n:fd1;<br>
FD_SET(fd2,&rfds);<br>
n=n>fd2?n:fd2;<br>
<br>
Where n is an integer. <br>
Now I call the select function as follows.....<br>
<br>
retval=select(n+1,&rfds,&wfds,NULL,NULL);<br>
<br>
Now to my surprise fd_set "rfds" contain both fd1 and fd2 being
set.(Moreover I can't write on to fd1 using "write" ..after select
returns !!!)<br>
and fd_set "wfds" too contain both of the descriptors. Iam really
surprised at results. FD_ISSET is reporting +ve value for both the fds
in both the fd_sets. How this can be possible...Is this a bug in select
..or I am wrong somewhere??? <br>
<br>
<br>
Thanks & Regards<br></div><span class="sg">
Nayyar<br>
</span>