[Top][All Lists]

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

Re: Simple sleep scripts causes SEGFAULT

From: Eduardo Bustamante
Subject: Re: Simple sleep scripts causes SEGFAULT
Date: Wed, 25 Oct 2017 23:32:41 -0500

On Wed, Oct 25, 2017 at 11:21 PM, Alex Coffin <address@hidden> wrote:
> Description:
>     Segmentation fault. I'm honestly not sure why. I was using batsh to
> make a simple script. When I ran it generated a segfault. The segmentation
> fault DOES NOT occur if "sleep" is replaced with "echo".
>     I also ran it on "GNU bash, version 4.4.12(1)-release
> (x86_64-redhat-linux-gnu)" using codingground (
> https://www.tutorialspoint.com/execute_bash_online.php) the same issue
> occurred.
> Repeat-By:
>     Run the following script (assuming you trust me lol):
>     function sleep {
>       local dur
>       dur="$1"
>       # if replaced with "echo" no segfault.
>       sleep ${dur}s
>     }
>     "sleep" $((5))

You are running the `sleep` function recursively, therefore exhausting
the stack of the bash process. I believe you intended to do something
like this instead:

sleep() {
  command sleep "$.."

reply via email to

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