Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

why this is a fork bomb?

0 views
Skip to first unread message

Bo Yang

unread,
Nov 22, 2008, 10:43:01 PM11/22/08
to
Hi,
Following is the famous fork bomb, but I don't understand why it
can:

:(){ :|:& };:

could you please help to explain this? Thanks a lot.

Regards!
Bo

Иван

unread,
Nov 22, 2008, 11:00:27 PM11/22/08
to

Bo Yang

unread,
Nov 22, 2008, 11:05:26 PM11/22/08
to
On 2008-11-23, Иван <nb...@free.dom> wrote:
> On Sat, 22 Nov 2008 19:43:01 -0800 (PST), Bo Yang <strug...@gmail.com> wrote :
>> Hi,
>> Following is the famous fork bomb, but I don't understand why it
>> can:
>>
>>:(){ :|:& };:
>>
>> could you please help to explain this? Thanks a lot.
>>
>> Regards!
>> Bo
>
> http://www.cyberciti.biz/faq/understanding-bash-fork-bomb/
> http://www.cyberciti.biz/tips/linux-limiting-user-process.html
>
> just googled fork bomb !
Sorry for my lazy, thanks a lot!

Regards!
Bo

Bo Yang

unread,
Nov 23, 2008, 4:03:37 AM11/23/08
to
On Nov 23, 11:43 am, Bo Yang <struggl...@gmail.com> wrote:
> Hi,
>   Following is the famous fork bomb, but I don't understand why it
> can:
>
> :(){ :|:& };:

bomb()
{
bomb &
bomb &
}; bomb

Does above works? I can't execute above code in my machine because it
is a server, if the code works, I then make a mistake...

I mean, do we need the PIPE between the two call exactly? Thanks!

Regards!
Bo

Andrew Smallshaw

unread,
Nov 23, 2008, 11:21:51 PM11/23/08
to

Either version will 'work' - the pipe is not needed per se, all
that is needed is for two children to be spawned at each iteration.
The key thing here is not the absolute number of processes, but
the number of simultaneously _runnable_ processes. Depending on
the precise syntax used, the caller will either termiminate after
spawning the processes or wait for them to terminate, neither of
which causes any particular problems. If each iteration only
creates a single new process then only one process is runnable at
any given time - this will waste CPU time but not cripple a system.
If the parent hangs around waiting for its children (which it won't
in the above examples) then you will likely hit the number of
processes per user limit before anything disastrous happens.

How you create two invocations doesn't really matter. Pipes are
one way, and &'s are another. The :(){ :|:& };: form has the
'advantage' of being obscured meaning that it is more likely that
you can persuade someone to run that code.

--
Andrew Smallshaw
and...@sdf.lonestar.org

Bo Yang

unread,
Nov 25, 2008, 8:48:30 PM11/25/08
to Bo Yang
On Nov 24, 12:21 pm, Andrew Smallshaw <andr...@sdf.lonestar.org>
wrote:

Yeah, the key point here it to make the shell fork new processes and
that is what '&' and '|' can do, I understand, thanks a lot!

Regards!
Bo

0 new messages