Search code examples
fish

How to make a fork bomb with fishshell?


I want to make a fork bomb with fishshell, but :(){ :|: & };: doesn't work and gives the error

fish: Command substitutions not allowed
:(){ :|: & };

How can I make a fork bomb with fishshell?


Solution

  • The syntax would have to be

    function forkbomb
        forkbomb | forkbomb &
    end
    forkbomb
    

    but:

    1. fish currently cannot background functions - it has no notion of forking off subshells, so there's no "fork" in your bomb
    2. fish recognizes that the function calls itself immediately and refuses because that's infinite recursion.

    What you can do is call fish manually, and define the function inside it:

    function forkbomb
        fish -C "$(functions forkbomb)" -c forkbomb | fish -C "$(functions forkbomb)" -c forkbomb &
    end
    

    Trigger it by running forkbomb. For obvious reasons this can bring your system to a halt.