shell 'trap' woodoo :)
Cristian Ionescu-Idbohrn
cristian.ionescu-idbohrn at axis.com
Mon Sep 13 21:52:26 UTC 2010
On Mon, 13 Sep 2010, Denys Vlasenko wrote:
> On Sun, Sep 12, 2010 at 10:31 PM, Cristian Ionescu-Idbohrn
> <cristian.ionescu-idbohrn at axis.com> wrote:
> >> # Automatically generated make config: don't edit
> >> # Busybox version: 1.18.0.git
> >> # Sun Sep 12 18:25:22 2010
>
> No, I need the ENTIRE .config, not its header.
Attached.
> > And back to something like previous test (ie. no sleep backgrounding and
> > 'wait $!', just straight sleep):
>
> And ENTIRE script.
./busybox_unstripped
BusyBox v1.18.0.git (2010-09-12 18:25:22 CEST) multi-call binary.
Both ash and hush built into that binary.
Shebang line is a symlink to v1.18.0.git busybox_unstripped binary.
---8<---
#!/home/me/bin/ash
set -e
set -u
#set -x
ZZZ=10
[ $# -lt 1 ] || ZZZ=$1
BEGIN=$(date +%s)
trap 'wrapper_func' EXIT TERM INT
other_func() {
local f=other_func
echo "in : $f" >&2
# XXX: if this doesn't fail, the expected exit status comes out after 'trap'
# but, if it _does_ fail, the exit status of the failed command will
# be returned, as errexit will step in.
ls -al /foo/bar/baz || :
echo "out: $f" >&2
}
wrapper_func() {
local f=wrapper_func tl= ign1 ign2 act s t=0
echo "in : $f" >&2
[ $(($(date +%s) - $BEGIN)) -ge $ZZZ ] ||
echo "0. : $f: interrupted" >&2
tl=$(trap)
[ -z "$tl" ] || {
echo "1. : $f: traps list" >&2
echo "$tl" >&2
while read ign1 ign2 act s; do
act=${act#\'}
act=${act%\'}
case $act in
$f)
trap - $s
t=$(($t + 1))
echo "2.$t: $f: $s trap removed" >&2
;;
esac
done <<-EOF
$tl
EOF
echo "3. : $f: listing traps again" >&2
trap
other_func
}
echo "out: $f" >&2
}
echo "running: ${0##*/}, pid: $$" >&2
sleep $ZZZ
#wait $!
exit 77
--->8---
> > ash:
> >
> > running: trap-test3.sh, pid: 30496
> > ^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
>
> And "strace -oLOG ..." output of this run.
I will. Tomorrow, I wish. Bed time now ;-)
> > hush:
> >
> > hush: set: -e: invalid option
> > hush: set: -u: invalid option
> > running: trap-test3.sh, pid: 30502
> > ^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
>
> And strace output of this run too.
Comming soon.
> Come on. You are long enough on this list to know that its purpose
> is not to vent "this shit doesn't f*cking work!!!" frustration.
> It is also not a place for guessing games.
Your're right. My bad :( I'll try to improve :)
> Please try to give enough information for bug to be diagnosed.
I'll do try that. Straces will show up on the list.
Cheers,
--
Cristian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 6094 bytes
Desc:
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20100913/5e744029/attachment-0001.obj>
More information about the busybox
mailing list