I'm using NSFileHandle in an ARC app on OS X Lion to read from a serial port.
Everything works fine 'till I go to close the port. I open the port with POSIX calls, set up some stuff, then instantiate an NSFileHandle with the file descriptor I got from open(). Then I call -readInBackgroundAndNotify, and a second file descriptor gets opened (I see this by using lsof). That FD gets closed the moment some data comes in and a notification gets posted, but I just go right back and call -readInBackgroundAndNotify again to get the next data. The problem is when I go to close the port. I still have a pending -readInBackgroundAndNotify, and so the port is opened twice. When I call -closeFile on the NSFileHandle, it closes the FD I initially opened, but leaves the second FD open. I tried setting the NSFileHandle reference to nil so that ARC would release it, and hopefully call -dealloc on it, but either it's not doing that, or -dealloc doesn't close that second FD either. In any case, when I go to open that port again, I get an error saying the resource is busy (if I quit my app, all FDs get closed). This sure seems like a bug to me. Am I doing something wrong? Thanks, Rick _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com