View Full Version : Bad File number?

05-30-2002, 02:10 PM
Alright, as some of you know, I downloaded Cygwin to compile Unix code under windows.

I have a MUD(Multi User Demension/Dungeon) that I am writing. I have a nice shell that allows player connection, and character creation. It compiled 100% fine under the Linux server I WAS using. Now I downloaded Cygwin, and I have a slight problem.

It compiles fine, with no errors. However, when I run the program it logs an error in the log files, and then shuts down.

Heres the error I got:
*Wed May 29 15:04:50 2002: mux select(): Bad file number*

And Heres the Code that uses that:

int max_files;

if ((max_files = getdtablesize()) == -1) {
log_to_file(LOG_ERRNO, "getdtablesize()");

is_running = TRUE;

while (is_running) {

FD_SET(control, &input_sfd);

for (con = first_con; con != NULL; con = con->next) {
FD_SET(con->sd, &input_sfd);
FD_SET(con->sd, &output_sfd);
FD_SET(con->sd, &exception_sfd);

if (select(max_files, &input_sfd, &output_sfd, &exception_sfd, &tv_zero) == -1) {
log_to_file(LOG_ERRNO, "mux select()");

Some of that may be irrelevent... but you can see the 'mux select()' part. I figured bad file number means that it can't log the error number? I'm not sure. And I've no clue why it would be messing up. I'm not a genius at sockets, and I followed a unix tutorial and fumbled my way through creating the basic MUD engine, but it works fine. Well, it used to. Nothing has changed sense I compiled on the server. does anyone have a clue to why it is not working? Or point me in a general direction?


05-30-2002, 02:15 PM
Sorry! I enetered my password wrong on the above post. Just wanted you all to know who was posting. -g- :D

05-30-2002, 08:50 PM
When using cygwin, there is a file in cywins' home directory something like "cygwing1.dll" or to that effect. this file has to be copied to the directory the executable is in.

I don't know if this is causing it cause I have no idea on MUD, except the stuff you played with when your a kid, and made pies out of. ;)

Hope I helped.


05-30-2002, 11:23 PM
It doesn't have a problem running the actual executable. Once the program runs, it goes into a loop and keeps checking each connection.

Thats where the problem comes in on the if statment of select().

05-31-2002, 08:55 AM
I can simulate this problem if I pass a file descriptor to select that is already closed.

Are you sure you are removing dead entries from the con list?