bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Debian bug #822605: SIGPIPE not handled in "echo >", terminates shel


From: Gioele Barabucci
Subject: Re: Debian bug #822605: SIGPIPE not handled in "echo >", terminates shell
Date: Thu, 21 Mar 2024 18:43:13 +0100
User-agent: Mozilla Thunderbird

On 21/03/24 18:08, Oğuz wrote:
On Thu, Mar 21, 2024 at 7:13 PM Gioele Barabucci <gioele@svario.it> wrote:
Regardless of the reason for the SIGPIPE, the reporter expects the loop
to carry on indefinitely (`while true; ...`).

Then he should do `trap '' PIPE' before the loop.

it is incorrect that > SIGPIPE terminates the subshell.

Why?

For various reasons. First of all, because it confuses users (there are various bug reports in Debian for this specific issue).

More technically, because non-builtin commands are treated differently, for example /bin/echo (from <https://bugs.debian.org/423207>):

    $ rm -f /tmp/f && mkfifo /tmp/f
    $ true </tmp/f &
    $ exec 3>/tmp/f
    $ bash -c 'exec >&3; exit 42'; echo $?
    42
    $ bash -c 'exec >&3; echo hi; exit 42'; echo $?
    141
    $ bash -c 'exec >&3; /bin/echo hi; exit 42'; echo $?
    42

...and because under the right conditions it may seemingly randomly close the interactive shell of the user:

    $ rm -f /tmp/f && mkfifo /tmp/f
    $ true </tmp/f &
    $ exec 3>/tmp/f
    $ exec >&3
    $ echo
    $ echo hi
    * shell exits *

Regards,

--
Gioele Barabucci



reply via email to

[Prev in Thread] Current Thread [Next in Thread]