[sane-devel] pthread support and MacOS X

Henning Meier-Geinitz henning@meier-geinitz.de
Wed, 8 Oct 2003 18:19:03 +0200


Hi,

On Wed, Oct 08, 2003 at 08:56:29AM +0200, Gerhard Jaeger wrote:
> 1.) I'd like to change the interface of the function to be called in the
>     forked process to: int func_to_call( void*). The adaption to the different
>     system-function will then be done in sanei_thread_begin. 
> --> int sanei_thread_begin( int(callback)(void*args), void *args)

Yes, that's ok I think. I've already thought about that because there
is no way to return a status with the current setup of void
func_to_call.

> 2.) waitpid: it's necessary to remove the specific macros WIF* etc from
>     the backend. Therefore it's also necessary to define one common
>     behaviour of sanei_thread_waitpid, regarding the return values and the
>     blocking of this call. Maybe the function should also be renamed to
>     show that it not only reflects waitpid functionality....
> 
> Any comments?

Do we need options at all? You are using WMOHANG in plustek.c but if
you kill() a process and after that waitpid () doesn't return because
no process has been killed something starnge has happened. I'd assume
that can't happen.

So just using the normal (blocking) waitpid may be enough.

Do we need to know if the process was killed or just exited? If we
don't need to know that something like this may be enough:

SANE_Status sanei_thread_wait (int pid, SANE_Status *child_status);

if waitpid (or pthread_join/pthread_detach) fails, return
SANE_STATUS_INVAL (or IOERROR or whatever), otherwise SANE_STATUS_GOOD.

client_status is the status of the process (WEXITSTATUS()) if it
exited normally or SANE_STATUS_GOOD (?) if it was killed. Or, if
necessary:

SANE_Status sanei_thread_wait (int pid, SANE_Bool *killed, SANE_Status *child_status);

*killed = SANE_TRUE if the process was killed. But I don't think it's
necessary.

Bye,
  Henning