Reputation: 4424
Sorry for asking such a general question but this has been bugging me for days.
A friend gave me this piece of code (?) and wont tell me what it does, or even if it is C or bash or anything else.
From the look of it, it looks like C to me. Although I dont get why there are :
on the sides.
:(){:|:&};:
Any clues will be appreciated.
Upvotes: 10
Views: 401
Reputation: 1170
This is a fork bomb and I would not run that on your system. It will cause a bunch of processes to spawn and ultimately slow down or crash your system.
Upvotes: 1
Reputation: 887509
This is bash shell script, not C.
It's a fork bomb.
Wikipedia explains it:
:() # define ':' -- whenever we say ':', do this:
{ # beginning of what to do when we say ':'
: # load another copy of the ':' function into memory...
| # ...and pipe its output to...
: # ...another copy of ':' function, which has to be loaded into memory
# (therefore, ':|:' simply gets two copies of ':' loaded whenever ':' is called)
& # disown the functions -- if the first ':' is killed,
# all of the functions that it has started should NOT be auto-killed
} # end of what to do when we say ':'
; # Having defined ':', we should now...
: # ...call ':', initiating a chain-reaction: each ':' will start two more.
Upvotes: 25