all 35 comments

sorted by: hot top controversial new old
[–] 60 points 1 year ago (14 children)

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

  • source
  • hideshow 14 child comments
  • [–] 143 points 1 year ago* (last edited 1 year ago) (7 children)

    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.
    
  • source
  • parent
  • hideshow 7 child comments
  • [–] 3 points 1 year ago (3 children)

    Why are the square brackets there?

  • source
  • parent
  • hideshow 3 child comments
  • [–] 4 points 1 year ago (1 child)

    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.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 62 points 1 year ago* (3 children)
    function tombombadil() {
       tombombadil | tombombadil & 
    }
    tombombadil()
    

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

  • source
  • parent
  • hideshow 3 child comments
  • [–] 3 points 1 year ago* (1 child)

    so basically

    10 print welcome to hell

    20 goto 10

    30 end

  • source
  • parent
  • hideshow 1 child comment
  • [–] 10 points 1 year 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.

  • source
  • parent
  • [–] 55 points 1 year ago (1 child)

    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"

  • source
  • parent
  • hideshow 1 child comment
  • [–] 7 points 1 year 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.

  • source
  • parent
  • [+] 47 points 1 year ago* (last edited 2 months ago) (5 children)
  • [+] 29 points 1 year ago (4 children)
  • [+] 15 points 1 year ago* (last edited 2 months ago) (3 children)
  • [+] 20 points 1 year ago (2 children)
  • [–] 24 points 1 year ago (1 child)

    my cats name is sudo rm -rf ~/

    its kinda weird i know

  • source
  • hideshow 1 child comment
  • [–] 20 points 1 year ago

    Bobby Table's evil cat?

  • source
  • [–] 19 points 1 year ago

    Tried it, fish said it's not his name

  • source
  • [–] 18 points 1 year ago (1 child)

    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.

  • source
  • hideshow 1 child comment
  • [–] 11 points 1 year ago (2 children)

    Look at those eyes! They yearn foe destruction! Also have you tried this in macOS yet?

  • source
  • hideshow 2 child comments
  • [–] 6 points 1 year ago* (last edited 1 year ago) (1 child)

    Breaking MacOS is easy, if the fork bomb doesn't work just create a function which recursively writes files until the disk is full. Unless they fixed it in the past 5 years, at that point even when the OS is set to delete files directly, it will still fail to delete anything. I couldn't even remove anything with sudo rm -f, that just triggered a 'not enough space to remove file' error message.

    Found that out the hard way when a program borked itself and filled the entire drive with log files until there was not even a single byte left. Fortunately I had a very small file in the bin, clearing that still worked and those few bytes were enough to be able to perform file deletes again. Never bothered to find out why MacOS behaved that way as I was able to ditch that OS entirely not long after, but perhaps somebody else knows.

  • source
  • parent
  • hideshow 1 child comment
  • Yeah, the “disk too full to delete” thing is still a problem on MacOS. Usually you can solve it by booting into safe mode, because that has fewer startup processes. That usually gives you enough wiggle room to clear your trash can and go from there. But yeah, the worst case scenario basically requires a drive reformat.

  • source
  • parent
  • [–] 10 points 1 year ago
    [–] 7 points 1 year ago

    Just kill the parent, problem solved! Fastest hands in the west!

  • source
  • [–] 6 points 1 year ago
    [–] 5 points 1 year ago
    [–] 4 points 1 year ago

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

  • source