[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] Don't exit with zero in the trap handler
From: |
Blue Swirl |
Subject: |
Re: [Qemu-devel] [PATCH] Don't exit with zero in the trap handler |
Date: |
Sat, 25 Sep 2010 15:30:50 +0000 |
On Sat, Sep 25, 2010 at 12:01 PM, Loïc Minier <address@hidden> wrote:
> On Sat, Sep 25, 2010, Blue Swirl wrote:
>> It looks like dash and ksh are not compliant and use the return value
>> of echo or rm inside trap handler:
>> dash -c 'trap "sh -c \"exit 4\"; exit" 0 1 2 3 9 11 13 15;exit 3'; echo $?
>> 4
>
> I've filed https://bugs.launchpad.net/dash/+bug/647450 to track this
> and forwarded the bug to address@hidden
>
>> ksh -c 'trap "sh -c \"exit 4\"; exit" 0 1 2 3 9 11 13 15;exit 3'; echo $?
>> 4
>
> On my system, ksh is provided by zsh and zsh gets this right.
On OpenBSD, ksh is pdksh and it fails like dash.
> In the mean time, could you please pull the patch in QEMU? Without
> "exit" in the trap handler, the correct exit code will be returned.
I tried also saving the return value, but it does not work:
dash -c 'trap "ret=$?;echo ret: $ret;sh -c \"exit 4\";exit $ret" 0 1 2
3 9 11 13 15;sh -c "exit 5"; echo exit now $?;exit'; echo $?
exit now 5
ret:
4
ksh -c 'trap "ret=$?;echo ret: $ret;sh -c \"exit 4\";exit $ret" 0 1 2
3 9 11 13 15;sh -c "exit 5"; echo exit now $?;exit'; echo $?
exit now 5
ret:
4
bash -c 'trap "ret=$?;echo ret: $ret;sh -c \"exit 4\";exit $ret" 0 1 2
3 9 11 13 15;sh -c "exit 5"; echo exit now $?;exit'; echo $?
exit now 5
ret:
0
Perhaps a short comment should be added to warn against adding exit.
- [Qemu-devel] [PATCH] Don't exit with zero in the trap handler, Loïc Minier, 2010/09/24
- Re: [Qemu-devel] [PATCH] Don't exit with zero in the trap handler, Markus Armbruster, 2010/09/25
- Re: [Qemu-devel] [PATCH] Don't exit with zero in the trap handler, Loïc Minier, 2010/09/25
- Re: [Qemu-devel] [PATCH] Don't exit with zero in the trap handler, Blue Swirl, 2010/09/25
- Re: [Qemu-devel] [PATCH] Don't exit with zero in the trap handler, Loïc Minier, 2010/09/25
- Re: [Qemu-devel] [PATCH] Don't exit with zero in the trap handler, Markus Armbruster, 2010/09/25
- Re: [Qemu-devel] [PATCH] Don't exit with zero in the trap handler,
Blue Swirl <=
- [Qemu-devel] [PATCH] Avoid exit in trap as it breaks with some shells, Loïc Minier, 2010/09/25
- Re: [Qemu-devel] [PATCH] Avoid exit in trap as it breaks with some shells, Blue Swirl, 2010/09/26