• riwo
    link
    fedilink
    English
    arrow-up
    59
    ·
    1 day ago

    what does it do? (no i am not trying it on my machine)

    • Delta_V@lemmy.world
      link
      fedilink
      English
      arrow-up
      137
      ·
      1 day ago

      This is a Bash fork bomb, a malicious function definition that recursively calls itself:

      :() — defines a function named : (yes, just a colon).
      
      { [:|:&] } — the function's body:
      
          :|: — pipes the output of the function into another call of itself, creating two processes each time.
      
          & — runs the call in the background, meaning it doesn’t wait for completion.
      
      ; — ends the function definition.
      
      : — finally, this invokes the function once, starting the bomb.
      
      • celeste@feddit.org
        link
        fedilink
        English
        arrow-up
        12
        ·
        1 day ago

        thx, I think I get it, it’s do it’s as many processes as your computer will run until it crashes

        • Delta_V@lemmy.world
          link
          fedilink
          English
          arrow-up
          1
          ·
          15 hours ago

          because I didn’t know what it did either, then made a typo in the ChatGPT prompt when asking about it

        • Peruvian_Skies@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          4
          ·
          23 hours ago

          There aren’t any square brackets.

          The form “function(){content}” in bash defines a function called “function” that, when called by name, executes “content”. This forkbomb defines a function called : (just a colon) which calls itself twice in a new subprocess (the two colons inside the curly brackets). It thus spawns more and more copies of itself until it overwhelms your processor.

    • tetris11@lemmy.ml
      link
      fedilink
      English
      arrow-up
      61
      ·
      edit-2
      1 day ago
      function tombombadil() {
         tombombadil | tombombadil & 
      }
      tombombadil()
      

      Each time it calls itself, it forks a background copy too and sends Gandalf deeper into the abyss

      • katy ✨
        cake
        link
        fedilink
        English
        arrow-up
        3
        ·
        edit-2
        1 day ago

        so basically

        10 print welcome to hell

        20 goto 10

        30 end

        • chaos@beehaw.org
          link
          fedilink
          English
          arrow-up
          9
          ·
          24 hours ago

          It’s worse, a single infinite loop will warm up the computer a bit, this program starts two copies of itself, each of which starts two copies of itself… unless you’ve set some limits on things the computer’s going to be locked up within seconds.

      • riwo
        link
        fedilink
        English
        arrow-up
        7
        ·
        1 day ago

        sounds likr there is some crazy lotr lore behind this

    • bdonvr@thelemmy.club
      link
      fedilink
      English
      arrow-up
      54
      ·
      1 day ago

      It just takes all your computers CPU and RAM by making endless copies of itself. Best case your PC gets sluggish, worst it crashes. Won’t do any lasting damage. It’s called a “Fork Bomb”

      • superkret@feddit.org
        link
        fedilink
        English
        arrow-up
        7
        ·
        1 day ago

        Any modern Linux system where you didn’t explicitly tell it to do otherwise will limit the amount of running processes to a safe number.
        So this does nothing anymore. Same as rm -rf / which also simply triggers an error message.