[sane-devel] scanadf --scan-script giving me troubles when used in screen environment

Jelle de Jong jelledejong at powercraft.nl
Mon Feb 9 18:29:02 UTC 2009


Simon Matter wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Jelle de Jong wrote:
>>> Hello everybody,
>>>
>>> I have developed this tool that uses scanadf:
>>> https://secure.powercraft.nl/svn/packages/trunk/deb/pct-scanner-scripts/pct-scanner-scripts-devel/
>>>
>>> It is also waiting for sponsoring to be included into debian:
>>> http://mentors.debian.net/debian/pool/main/p/pct-scanner-scripts
>>>
>>> The tool works fine run from the command line but when trying to
>>> integrate it with keyboard shortcuts i run into serious trouble. I
>>> spent a hole day trying to debug it without luck.
>>>
>>> The script called from scanadf closes unexpected when executing a
>>> command like c44 of convert, i first thought it was a bug in convert
>>> so i made this bug report, see the attachment for info:
>>> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=513493
>>>
>>> But then after further testing I had exactly the same issue with c44
>>> command.
>>>
>>> It only happens when my tool is not directly executed form a terminal.
>>>
>>> If i run this from a normal xterm of xfce4-terminal it goes wrong:
>>> screen -S scanner /usr/bin/pct-scanner-script --config color2 --clean
>>> or
>>> /usr/bin/xfce4-terminal --hold --execute /usr/bin/pct-scanner-script
>>> --config color2
>>>
>>> So its not only with screen i get this issue....
>>>
>>> Both above command result in an unexpected exit of the child script
>>> used by scanadf.
>>>
>>> I also simplified the script that is called form scanadf but it just
>>> dies unexpected when called: see: http://debian.pastebin.com/d5f169270
>>>
>>> I am complete lost here, I have been pulling out my remaining hairs
>>> for this hole day :-(
>>>
>>> I can both duplicate this issue on two different machines one lenny
>>> and one sid.
>>>
>>> Please help,
>>>
>>> Best regards,
>>>
>>> Jelle de Jong
>>>
>> Hello everybody,
>>
>> After more debugging with strace I discovered that the running command
>> received a SIGHUP [1] singal, I tried all kind of things like wait,
>> nohup, disown to keep the script called by scanadf running, but no
>> luck. [1] --- SIGHUP (Hangup) @ 0 (0) ---
> 
> Am I correct that your script is called from scanadf and it then receives
> SIGHUP after some time of running? If yes, did you try disabling bash's
> standard SIGHUP handling (which is to send SIGHUP also to it's children)
> 
> trap "" SIGHUP
> 
> IIRC another problem can be vanishing filedescriptors, like STDIN going
> missing. I see that you run some programs in background with nohup. If you
> want them to run completely independant you could try runnning them with
> disconnected filedescriptors, like
> 
> program <&- >&- 2>&- &
> 
> Of course that can be impossible if you need them but depending of how
> your program works it may be a solution.
> 
> Regards,
> Simon
> 

Thanks for the hints, I did not try to use the trap or redirections
since I think the default behavior is kind of broken.

Would somebody be willing to take a look at it?

I also have the following question:

I created the below project:
http://mentors.debian.net/debian/pool/main/p/pct-scanner-scripts/

It is a bash script that wraps all kind of extra functionality to the
scanadf tool. Maybe it would be nice if somebody could make scanadf2
or scantool for it as evolution or enhancement of the original tool?

Best regards,

Jelle de Jong






More information about the sane-devel mailing list