Problems with select


 
Thread Tools Search this Thread
Top Forums Programming Problems with select
# 1  
Old 02-10-2010
Problems with select

Is select only supposed to report state changes on an FD's, state, whether or not it had pending input available in the first place? I've got a situation where select() repeatedly reports no FD's ready for stdin when there's lots of data available. And if it only reports changes, how is this useful? It's impossible to guarantee an FD has no pending data before you call select(), making its return value meaningless at worst and at best a crapshoot.
# 2  
Old 02-10-2010
Around 22 years ago I had similar problems with select on HP-UX. I would have thought these bugs would be worked out by now.
# 3  
Old 02-10-2010
The behavior seems to be standardized. The linux page even specifically mentions looking for state changes, rather than describing it as "pending data". Presumably there's a "proper" way to use it I hope, that's better than "wait for it to timeout and check all possible streams regardless".

---------- Post updated 02-10-10 at 12:56 AM ---------- Previous update was 02-09-10 at 11:58 PM ----------

I think I've found a way that works: Ignore select's return values, which only seem to report state changes, and look at the FD_ISSET values, which actually do seem to represent pending data.

---------- Post updated at 01:07 AM ---------- Previous update was at 12:56 AM ----------

That's not it either. But I finally found a clear, working example: You have to FD_SET the FD's you want every single loop, not just once; if data isn't available, select() will clear them for you.

Last edited by Corona688; 02-10-2010 at 02:22 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Select command

Hi I'm using the "select" command in the global_env.sh to log in to the application directory. This file is called in .bashrc profile. Sample code: Filename: global_env.sh set -o vi export severname=$(uname -n) printf '%s\n%30s\n%s\n' "***********************" "Welcome to $severname"... (6 Replies)
Discussion started by: cheers799
6 Replies

2. Windows & DOS: Issues & Discussions

Need help in select statetment

Dear Expert, I have an table name (SMS) in which two column are there one "Flag" other is "Message", If my flag column consist of status "1" then output should be "welcome", else" try again" ,. please correct my code. DECLARE c PLS_INTEGER := dbms_sql.open_cursor; flag VARCHAR2(50); ... (1 Reply)
Discussion started by: Alone
1 Replies

3. Boot Loaders

Reboot and Select Proper Boot device or insert Boot media in select Boot device and press a key

Hello, I have kubuntu on my laptop and now I decided to switch to Windows 7. I made the bios settings properly (first choice is boot from cd\vd) but I see the error " reboot and select proper Boot device or insert Boot media in select Boot device and press a key " I have tried CD and... (0 Replies)
Discussion started by: rpf
0 Replies

4. Shell Programming and Scripting

using the output of select

hi, i need to use the output of select query. the output i get using "X=`sqlplus -s $var1/$var1<<eof select port from table1;` echo $X " is "port ----- 2000" now i want to use only 2000 in my next command. hw do i do it? (4 Replies)
Discussion started by: deep_bree
4 Replies

5. Shell Programming and Scripting

Select Script

Dear Members:- i want to make this script 1- i have a log directory /export/home/roxy/log 2- file name in this directory with this format filename_DD_MM_YYYY_%H%M%S.log i want to make script for example: # script.sh _09_04_2009_ _10_04_2009_ this script make select to log file into... (4 Replies)
Discussion started by: dellroxy
4 Replies

6. Shell Programming and Scripting

select a particular field

hi i have a file wwww-qqq.eee ksdklfsdf adm,as.d,am sdsdlasdjl sadsadasda wwww-qqq.eee ksdklfsdf adm,as.d,am sdsdlasdjl sadsadasda wwww-qqq.eee ksdklfsdf adm,as.d,am sdsdlasdjl sadsadasda wwww-qqq.eee ksdklfsdf adm,as.d,am sdsdlasdjl sadsadasda wwww-qqq.eee ksdklfsdf adm,as.d,am... (4 Replies)
Discussion started by: Satyak
4 Replies

7. Shell Programming and Scripting

select a column

I've a file like this: andrea andre@lol.com october antonio@lol.com marco 45247@pop.com kk@pop.com may pollo@lol.com mary mary@lol.com can I select only the column with email adress? can I utilise a filter with @ ? I want obtain this: ... (2 Replies)
Discussion started by: alfreale
2 Replies

8. Programming

select function

Dear all, I am using select function for the socket programming. What is the purpose of except fd's fd set in the argument. (0 Replies)
Discussion started by: nagalenoj
0 Replies

9. Programming

Problems with pipe(...); using select(...);

Hello all, My problem is as follows: I'm trying to wake up a select(...); using a pipe fd. This should be rather straightforward, but I cannot get it to work. Perhaps you guys could give me a few tips. My wakeup function looks like this: STATIC void net_trig_wr() { /* write a dummy... (0 Replies)
Discussion started by: ne2000
0 Replies

10. UNIX for Advanced & Expert Users

'make' problems (compliation problems?)

I'm trying to compile and install both most recent version of 'make' and the most recent version of 'openssh' on my Sparc20. I've run into the following problems... and I don't know what they mean. Can someone please help me resolve these issues? I'm using the 'make' version that was... (5 Replies)
Discussion started by: xyyz
5 Replies
Login or Register to Ask a Question