• bdonvr@thelemmy.club
      link
      fedilink
      English
      arrow-up
      51
      ·
      3 months 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”

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

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

        • chaos@beehaw.org
          link
          fedilink
          English
          arrow-up
          9
          ·
          3 months 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.

    • Delta_V@lemmy.world
      link
      fedilink
      English
      arrow-up
      135
      arrow-down
      1
      ·
      edit-2
      2 months 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.
      
        • Peruvian_Skies@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          3
          ·
          3 months 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.

          • baduhai@sopuli.xyz
            link
            fedilink
            English
            arrow-up
            4
            ·
            edit-2
            3 months ago

            I understood, it’s just that @Delta_V@lemmy.world added square brackets to his explanation.

            { [:|:&] } — the function's body:

        • Delta_V@lemmy.world
          link
          fedilink
          English
          arrow-up
          1
          ·
          3 months ago

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

  • Farid@startrek.website
    link
    fedilink
    English
    arrow-up
    17
    ·
    3 months ago

    I had a class about fork() on my Operating Systems course yesterday. I was going to look up the fork bomb, that the teacher didn’t even tell us about >:( , but it somehow found me instead.

  • Lvxferre [he/him]@mander.xyz
    link
    fedilink
    English
    arrow-up
    46
    ·
    edit-2
    3 months ago

    I love telling excited newbies to run this forkbomb. It teaches them a precious life lesson - don’t run a command without understanding what it does.

  • yuri@pawb.social
    link
    fedilink
    English
    arrow-up
    4
    ·
    3 months ago

    ah, fond memories of accidentally forkbombing my middle school computer in the middle of typing class…