diff mbox

Avoid exit in trap as it breaks with some shells

Message ID 1285444350-16679-1-git-send-email-loic.minier@linaro.org
State New
Headers show

Commit Message

Loïc Minier Sept. 25, 2010, 7:52 p.m. UTC
Don't call exit in the trap handler as it causes the return code to be
zero with some buggy shells (dash and pdksh at least) and is useless
here anyway.
---
 configure |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

Comments

Blue Swirl Sept. 26, 2010, 6:58 a.m. UTC | #1
Thanks, applied. Please remember to add the Signed-off-line.

On Sat, Sep 25, 2010 at 7:52 PM, Loïc Minier <loic.minier@linaro.org> wrote:
> Don't call exit in the trap handler as it causes the return code to be
> zero with some buggy shells (dash and pdksh at least) and is useless
> here anyway.
> ---
>  configure |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/configure b/configure
> index 3bfc5e9..9d3acfc 100755
> --- a/configure
> +++ b/configure
> @@ -15,7 +15,9 @@ TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
>  TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
>  TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
>
> -trap "rm -f $TMPC $TMPO $TMPE ; exit" EXIT INT QUIT TERM
> +# NB: do not call "exit" in the trap handler; this is buggy with some shells;
> +# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
> +trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
>
>  compile_object() {
>   $cc $QEMU_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
> --
> 1.7.1
>
>
>
Peter Maydell May 19, 2014, 4:30 p.m. UTC | #2
On 25 September 2010 20:52, Loïc Minier <loic.minier@linaro.org> wrote:
> Don't call exit in the trap handler as it causes the return code to be
> zero with some buggy shells (dash and pdksh at least) and is useless
> here anyway.
> ---
>  configure |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/configure b/configure
> index 3bfc5e9..9d3acfc 100755
> --- a/configure
> +++ b/configure
> @@ -15,7 +15,9 @@ TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
>  TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
>  TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
>
> -trap "rm -f $TMPC $TMPO $TMPE ; exit" EXIT INT QUIT TERM
> +# NB: do not call "exit" in the trap handler; this is buggy with some shells;
> +# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
> +trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
>
>  compile_object() {
>    $cc $QEMU_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
> --
> 1.7.1

Dragging up this ancient thread from 2010 to note that this
change turns out to have an undesirable effect: if you hit
^C at QEMU, the trap handler will run (good) but the shell
won't actually exit (bad!), and we will continue to run through
the rest of the configure script after removing the temporaries.

I guess we need to figure out an alternate approach to the
problem noted in the msgid/commit message.

thanks
-- PMM
diff mbox

Patch

diff --git a/configure b/configure
index 3bfc5e9..9d3acfc 100755
--- a/configure
+++ b/configure
@@ -15,7 +15,9 @@  TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
 TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
 TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
 
-trap "rm -f $TMPC $TMPO $TMPE ; exit" EXIT INT QUIT TERM
+# NB: do not call "exit" in the trap handler; this is buggy with some shells;
+# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
+trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
 
 compile_object() {
   $cc $QEMU_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null