本文介绍了如何做到这一点的bash fork炸弹的工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据维基百科,以下是一个非常优雅的bash叉炸弹:

According to Wikipedia, the following is a very elegant bash fork bomb:

:(){ :|:& };:

它是如何工作的?

How does it work?

推荐答案

打破下来,有三大块:

:()      # Defines a function, ":". It takes no arguments.
{ ... }; # The body of the function.
:        # Invoke the function ":" that was just defined.

在主体内部,该函数被调用两次,并在管道被后台运行;在处理每一个连续调用产卵更呼吁:。这迅速导致爆炸性消耗系统资源,磨东西停了下来。

Inside the body, the function is invoked twice and the pipeline is backgrounded; each successive invocation on the processes spawns even more calls to ":". This leads rapidly to an explosive consumption in system resources, grinding things to a halt.

请注意,调用了一次,无限递归,就不够好,因为这只会导致对原工艺堆栈溢出,这是混乱,但可以处理。

Note that invoking it once, infinitely recursing, wouldn't be good enough, since that would just lead to a stack overflow on the original process, which is messy but can be dealt with.

一个更人性化的版本是这样的:

A more human-friendly version looks like this:

kablammo() {             # Declaration
  kablammo | kablammo&   # The problematic body.
}; kablammo              # End function definition; invoke function.

编辑:下面威廉的意见就是我上面说的更好的措辞,所以我已经编辑把这项建议

William's comment below was a better wording of what I said above, so I've edited to incorporate that suggestion.

这篇关于如何做到这一点的bash fork炸弹的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 09:47