Hi all, first time poster to this list, hope that this is right list
to post to...
I've adapted some code to my own uses (shown below) but have run into
an odd problem, and I'm hoping that someone can explain what is going
on to me. As a part of my open_TTY_OSX() function, I call ioctl
(context->fileDescriptor, TIOCEXCL), which prevents any non-root
program from opening the same device. Now this is where it gets odd
for me. I am testing all this code using some unit tests that I
wrote. The unit tests call open_TTY_OSX() and then balance the call
with a call to close_TTY_OSX() on the same file descriptor.
Originally, I did NOT have the ioctl(context->fileDescriptor,
TIOCNXCL) call in close_TTY_OSX(), and the result was that if I tried
to open the same device again, it would fail with EBUSY. So basically:
open_TTY_OSX("/dev/ttyp1", foo) // no problem
close_TTY_OSX(foo) // no problem
open_TTY_OSX("/dev/ttyp1, bar) // Fails with EBUSY
Well, I figured that this isn't that big a deal, I just let my
process exit nicely, and the restart the debugging session, right?
No good. The only way for me to make things play nice is to quit
XCode, and even that doesn't seem to work 100% of the time. My
question is why? When I close, I reset the attributes, and I close()
the descriptor. That should make the blocking part go away, right?
What am I doing wrong?
Oh, note that adjAssert() is a macro like assert(); I just hacked in
some extra stuff that I needed, and didn't what the names conflicting.
result = close(context->fileDescriptor);
if (result != 0)
perror(NULL);
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden