Networking Forums

Networking Forums > Computer Networking > Linux Networking > Does select thread safe in kernel 2.4.x

Reply
Thread Tools Display Modes

Does select thread safe in kernel 2.4.x

 
 
Readon Shaw
Guest
Posts: n/a

 
      09-07-2006, 04:16 AM
I am using select in two thread, one get fd with 0, the other
is 14. when i select() them, it would return -1 and the error reported
that "bad file descriptor". does select a thread safe function?
ps: when the fd is 14 and 15, the system works well.

 
Reply With Quote
 
 
 
 
David Schwartz
Guest
Posts: n/a

 
      09-07-2006, 07:20 AM

Readon Shaw wrote:

> I am using select in two thread, one get fd with 0, the other
> is 14. when i select() them, it would return -1 and the error reported
> that "bad file descriptor". does select a thread safe function?
> ps: when the fd is 14 and 15, the system works well.


If 'select' returns -1 and the error is "bad file descriptor", that
means you have a bug in your code that cause you to call 'select' with
an fd set that is bad in some way.

Yes, 'select' is a thread safe function.

It's hard to tell what your problem is from such a vague description,
but one possibility might be that somewhere in your code, you close
file descriptor zero (or are invoked without one). Then your code just
assumes that there must be a valid 'stdin', so 'select's on it. This
will return "bad file descriptor" if no files have been opened. It can
do much worse things if one has.

DS

 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
select-like implementation for kernel sockets eitanr@audiocodes.com Linux Networking 0 05-06-2007 10:56 AM
killing a kernel thread ....... UDP server (kernel module)......... alex Linux Networking 0 09-20-2006 11:26 AM
Are sockets thread safe jainarunk@gmail.com Linux Networking 15 06-16-2006 05:51 AM
Re: Sending UDP Packets from a kernel thread/module Tim Roberts Linux Networking 10 12-19-2005 01:32 PM
Re: Sending UDP Packets from a kernel thread/module phil-news-nospam@ipal.net Linux Networking 0 12-05-2005 11:54 AM



1 2 3 4 5 6 7 8 9 10 11