On 6/21/24 1:26 PM, Mikhail Gavrilov wrote:
On Fri, Jun 21, 2024 at 10:06 PM Chet Ramey <chet.ra...@case.edu> wrote:

It's a bug in the script. If you want to run `kill 0', which sends SIGTERM,
from a SIGTERM trap handler, you need to reset the SIGTERM trap to the
default before doing so.

Bash allows recursive trap handlers.

What's happening is you're recursively invoking the trap handler until
you exceed the stack space resource limit. Bash has an internal limit on
how many times you can recursively eval a trap handler, but you run out
of stack space before exceeding it.

Ok. But it's very suspicious for me because the script ended without
any issues on macOS.

mikhail@MBP-Mikhail ~> ./splitcurl.sh "ftp://test.rebex.net/no-file"; 10
Download failed!
mikhail@MBP-Mikhail ~>
mikhail@MBP-Mikhail ~> bash --version
GNU bash, version 3.2.57(1)-release (arm64-apple-darwin24)
Copyright (C) 2007 Free Software Foundation, Inc.
mikhail@MBP-Mikhail ~>

Because this is a feature that was added between 2007 and now. Bash-3.2
didn't allow recursive trap handler invocations.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to