<div>Hello ,<br><br>
I am right now implementing test case for &quot;select&quot; 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(&quot;touch tmp1;echo absjkhsk&gt;tmp1;chmod 400 tmp1&quot;);<br>
system(&quot;touch tmp2;echo jhagsakjg&gt;tmp2;chmod 200 tmp2&quot;);<br>
<br>
Now I opened the files as follows..<br>
<br>
fd1=open(&quot;tmp1&quot;,O_RDONLY);<br>
fd2=open(&quot;tmp2&quot;,O_WRONLY);<br>
<br>
Now I added both the&nbsp; file descriptors in &quot;rfds&quot; and &quot;wfds&quot; (Basically defined as &quot;fd_set rfds,wfds; &quot;) as follows...<br>
<br>
FD_SET(fd1,&amp;rfds);<br>
n=n&gt;fd1?n:fd1;<br>
FD_SET(fd2,&amp;wfds);<br>
n=n&gt;fd2?n:fd2;<br>
FD_SET(fd1,&amp;wfds);<br>
n=n&gt;fd1?n:fd1;<br>
FD_SET(fd2,&amp;rfds);<br>
n=n&gt;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,&amp;rfds,&amp;wfds,NULL,NULL);<br>
<br>
Now to my surprise fd_set &quot;rfds&quot; contain both fd1 and fd2 being
set.(Moreover I can't write on to fd1 using &quot;write&quot; ..after select
returns !!!)<br>
and fd_set &quot;wfds&quot; 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 &amp; Regards<br></div><span class="sg">
Nayyar<br>
</span>