[sane-devel] scanimage hangs at shutdown (Preparing for a sane-backends release)
Rolf Bensch
rolf at bensch-online.de
Wed Aug 19 08:23:35 UTC 2015
Hi Olaf,
Good idea, but it doesn't work. Many thanks for your help.
Cheers,
Rolf
Am 19.08.2015 um 03:27 schrieb Olaf Meeuwissen:
>
> Rolf Bensch writes:
>
>> Using fork or pthread makes no difference.
>>
>> A sleep at the end of main() works wonders.
>>
>> But not for the other exit() functions. 'scanimage -h' or 'scanimage -A'
>> still hang with the same issue.
>>
>> I suggest to replace atexit and all exit() functions by the existing
>> scanimage_exit() function.
>>
>> Please check if attached patch is running with your installations.
>
> I had a look at the patch and tripped over the fixme. Next, I had a
> look at the scanimage_exit() implementation and the timing of adding
> that to the list of functions to call atexit. Something definitely
> smells there.
>
> - scanimage_exit() may call sane_close(). That function may need to do
> device I/O.
> - scanimage_exit() is register with atexit() *before* sane_init() gets
> called. This means that any functions registered via atexit() in a
> backend run *before* scanimage_exit().
> - none of the backends call atexit() directly but any library they use
> may register exit handlers
>
> Is there any chance that the libusb-compat installations that are
> affected register an exit handler? Say something like libusb_exit()?
> If that is the case, device I/O will be made impossible *before*
> scanimage_exit() gets a chance to sane_close() the device.
>
> Note that the -h and -A options to scanimage need the device's options
> so that just about guarantees that its backend needs to talk to it.
>
> Does moving the atexit() call *after* sane_init() fix this issue?
>
> Hope this helps,
>
More information about the sane-devel
mailing list