dimme
dimme

Reputation: 4424

What is this piece of code doing? :(){:|:&};:

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

Answers (2)

in70x
in70x

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

SLaks
SLaks

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

Related Questions