Chinaunix首页 | 论坛 | 博客
  • 博客访问: 576946
  • 博文数量: 158
  • 博客积分: 2696
  • 博客等级: 少校
  • 技术积分: 1668
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-10 00:49
个人简介

life?is?short?,?play?more!

文章分类

全部博文(158)

文章存档

2021年(1)

2013年(10)

2012年(4)

2011年(11)

2010年(27)

2009年(28)

2008年(52)

2007年(25)

我的朋友

分类: LINUX

2011-04-08 00:27:04


bash中的冒号是内建命令

":" is a builtin shell command, and is equivalent to to the "true" command, it is used mostly as a placeholder in scripts.

永远返回真, 相当于一个站位符号.

可以用来注释,跨行注释

: 'this is
comment
!!'

如下是一个有冒号的,看似是一个命令. 会不断fork线程,导致机器崩溃.
但实际上, 这个和冒号命令无关.


:(){ :|:& };:

: 这里代表是定义了一个函数名字而已. 和下面的一段bash代码意义相同.

funcname() {
# Run 2 instances of the very same function
# in the background. Each of these new
# processes will do the same: each starts 2 new
# processes doing the same,... and again, and again..
funcname | funcname &
}

STUB: dont run this! It will probably halt your computer.

# Now just call the function to start forking
# bash processes indefinately.

funcname

# We will never get here.

如何让机器死机?

Perl exmaple:

perl -e "fork while fork" &

Python example:

import os
while(1):
os.fork()

Windows XP / Vista bat file example:

:bomb
start %0
goto bomb

UNIX style for Windows:

%0|%0

C program example:

#include
int main() { while(1) fork(); }

Plz note that the fork bomb is a form of denial of service, so don’t run on production or unauthorized system.


阅读(2545) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~