[sane-devel] pthreads for MacOSX (instead of child process)

Beat Birkhofer beat.birkhofer@ilw.agrl.ethz.ch
Wed, 5 Feb 2003 20:47:39 +0100


>Shouldn't the problem solved at the source, i.e. IOKit fixed or a
>workaound written for that one? Isn't there a way to get the
>priviledge for access for the second process?

The fork() problem was discussed on the Apple USB-Dev List. 
2002-12-11 two (!) Apple developers stated that fork() doesn't' work. 
Quotation:

>>I'm pretty sure you do not inherit the connection. The connection is
>>via a Mach port and the port is not inherited.
>>--
>>Barry Twycross
>>BarryT@Apple.com

Maybe the libusb one day provides a workaround.

>I think sanei_tread is the right way.

There are two backends that use it: mustek and microtek2. Both 
contain ifdefs for OS/2 (4 each file). sanei_cancel() probably works 
on OS/2 because the OS/2 thread uses something like a PID.

I would have to redefine kill, waitpid and fork in the 
MacOSX-Specific part of sanei_thread. This would work perhaps with 
some int <-> void* casting. I have currently no clue how I can use 
something like

if (s->reader_pid > 0)

with pthreads. With pthreads my 'PID' is a pointer.

>In fact, it's used currently by just #defining
>fork and other related functions. It seems to be more clear to really
>use an explicit sanei_thread_start or similar.

Yes, code readability suffers IMHO if system calls are redefined.

Regards

Beat H.