Opened 13 years ago

Closed 13 years ago

#5055 closed bug (fixed)

fdopendir closes file descriptor too early

Reported by: augiedoggie Owned by: nobody
Priority: normal Milestone: R1
Component: System/POSIX Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All


After the *at() functions were added in hrev34288, mercurial has been trying to use those functions. It is currently exiting because of a bad file descriptor when it tries to scan a directory using fdopendir()/readdir()/fstatat(). I believe the comment from dirent.c is correct and the file descriptor should not be closed in the fdopendir() function.

I will attach a small piece of sample code if I can get networking to work again(dhcp won't give me an address in hrev34349). The sample code is basically an excerpt from the mercurial code in osutil.c

Attachments (1)

fdtest.c (798 bytes ) - added by augiedoggie 13 years ago.
Code which fails on haiku, but runs on Linux (when run as 'fdtest .')

Download all attachments as: .zip

Change History (4)

by augiedoggie, 13 years ago

Attachment: fdtest.c added

Code which fails on haiku, but runs on Linux (when run as 'fdtest .')

comment:1 by axeld, 13 years ago

Well, the main reason this is breaking is because the code itself is broken; ie. it does not adhere to the specs (besides not using closedir() to close the directory).

However, if this is used this way in applications, and they do work on other platforms, I guess we should just follow their example.

comment:2 by augiedoggie, 13 years ago

Yes, it's not in my area of expertise, if I even have one :)

There is a closedir() in the mercurial code that I forgot to add to my test but I don't think it should affect the outcome because the error is before that part of code is even reached.

comment:3 by axeld, 13 years ago

Resolution: fixed
Status: newclosed

Looks like newer specs have clarified the issue: and indeed, only closedir() should actually close the descriptor, and applications are allowed to use the descriptor without changing its state.

Should be fixed in hrev34362.

Note: See TracTickets for help on using tickets.