[sane-devel] RE: (Big?) Problem with fork() in OSX

Phil Barrett phil@cambridgeanimation.com
Wed, 18 Dec 2002 14:39:47 -0000


> If the file descriptors aren't dup'ed, that should be fixed on MacOS
> and not SANE. That's one of the basic Unix functions and if it doesn't
> work, it's just not Unix.
>
> However, bugs in fork would harm a lot of other applications so I
> wonder if this is the real reason.

There are no bugs in fork() or with file descriptors (or at least, none
relevant to the current discussion). The problem is that Mac OS X IO access
is not (and indeed cannot be) made through file descriptors. The Darwin IO
libraries are another breed completely.

See
http://developer.apple.com/techpubs/macosx/Darwin/IOKit/DeviceInterfaces/SCS
IArchitectureModel/SAMDocPage.html

The problem is that after you call (*taskinferface->ObtainExclusiveAccess)()
a fork()ed thread is then denied access because the first thread has
exclusive access.

Phil