shell 'trap' woodoo :)

Denys Vlasenko vda.linux at googlemail.com
Mon Sep 13 13:30:52 UTC 2010


On Sun, Sep 12, 2010 at 7:42 PM, Cristian Ionescu-Idbohrn
<cristian.ionescu-idbohrn at axis.com> wrote:
> On Sun, 12 Sep 2010, Denys Vlasenko wrote:
>
>> I definitely see current ash and hush to react to ^C at once.
>
> I don't (after 'git pull')
>
>> I also tested Rob's prebuilt busybox-i486 binary (v.1.17.2) from
>> http://impactlinux.com/aboriginal/downloads/binaries/extras/
>> Here is test runs:
>>
>> # ./busybox-i486 ash z
>> running: z
>> ^Cin : wrapper_func
>> in : wrapper_func
>> 1. : wrapper_func: listing traps
>> trap -- 'wrapper_func' INT
>> trap -- 'wrapper_func' TERM
>> 2. : wrapper_func: removing traps
>> 3. : wrapper_func: listing traps again
>> in : other_func
>> ls: cannot access /foo/bar/baz: No such file or directory
>> out: other_func
>> out: wrapper_func
>> 1. : wrapper_func: listing traps
>> 2. : wrapper_func: removing traps
>> 3. : wrapper_func: listing traps again
>> in : other_func
>> ls: cannot access /foo/bar/baz: No such file or directory
>> out: other_func
>> out: wrapper_func
>
> running: trap-test3.sh, pid: 23879
> ^Cin : wrapper_func
> 0. : wrapper_func: interrupted
> 1. : wrapper_func: traps list
> trap -- 'wrapper_func' INT
> trap -- 'wrapper_func' TERM
> 2.1: wrapper_func: INT trap removed
> 2.2: wrapper_func: TERM trap removed
> 3. : wrapper_func: listing traps again
> in : other_func
> ls: /foo/bar/baz: No such file or directory
> out: other_func
> out: wrapper_func
> in : wrapper_func
> 0. : wrapper_func: interrupted
> out: wrapper_func
>
> Still not showing the EXIT trap and running twice, but behaves.

Is this the run of *Rob's binary busybox-i486* on your machine?
I don't see the starting line, I can only guess whether it is
"./busybox-i486 ..." run or "./busybox ..." run.


>> # ./busybox-i486 hush z
>> hush: set: -e: invalid option
>> hush: set: -u: invalid option
>> running: z
>> ^C
>> in : wrapper_func
>> 1. : wrapper_func: listing traps
>> trap -- 'wrapper_func' EXIT
>> trap -- 'wrapper_func' INT
>> trap -- 'wrapper_func' TERM
>> 2. : wrapper_func: removing traps
>> 3. : wrapper_func: listing traps again
>> in : other_func
>> ls: cannot access /foo/bar/baz: No such file or directory
>> out: other_func
>> out: wrapper_func
>
> hush: set: -e: invalid option
> hush: set: -u: invalid option
> running: trap-test3.sh, pid: 23618
> ^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^Cin : wrapper_func
> 1. : wrapper_func: traps list
> trap -- 'wrapper_func' EXIT
> trap -- 'wrapper_func' INT
> trap -- 'wrapper_func' TERM
> 2.1: wrapper_func: EXIT trap removed
> 2.2: wrapper_func: INT trap removed
> 2.3: wrapper_func: TERM trap removed
> 3. : wrapper_func: listing traps again
> in : other_func
> ls: /foo/bar/baz: No such file or directory
> out: other_func
> out: wrapper_func
>
> Slightly modified test script, attached.  Still, SIGINT not catched, looks
> like.  I even did a 'distclean' and rebuilt.

Is this the run of *Rob's binary busybox-i486* on your machine?


>> # ./busybox-i486
>> BusyBox v1.17.2 (2010-09-05 04:58:49 CDT) multi-call binary.
>> ...
>
> ./busybox_unstripped
> BusyBox v1.18.0.git (2010-09-12 18:25:22 CEST) multi-call binary.
>
>> I don't see this in my experiments.
>
> I do.  Wonder what the cause is.  I guess gcc is different:

Lets do something to stop guessing and start getting solid facts.
Can you TRY Rob's binary to test this theory?

I can also build a statically linked busybox and send it to you
so that you can run it too.
But I need your .config first.

-- 
vda


More information about the busybox mailing list