Bash 命令 :(){ :|:&};: 将产生进程导致内核死亡.你能解释一下语法吗? [英] The Bash command :(){ :|:& };: will spawn processes to kernel death. Can you explain the syntax?

查看:13
本文介绍了Bash 命令 :(){ :|:&};: 将产生进程导致内核死亡.你能解释一下语法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看了这个页面并且无法理解这是如何工作的.

I looked at this page and can't understand how this works.

此命令以指数方式生成子进程,直到您的盒子锁定为止".

This command "exponentially spawns subprocesses until your box locks up".

但是为什么呢?我不太了解的是冒号.

But why? What I understand less are the colons.

user@host$ :(){ :|:&};:

推荐答案

它定义了一个名为 : 的函数,它会调用自己两次(代码:: | :).它在后台执行此操作 (&).在 ; 之后,函数定义完成,函数 : 开始运行.

That defines a function called : which calls itself twice (Code: : | :). It does that in the background (&). After the ; the function definition is done and the function : gets started.

所以 : 的每个实例都会启动两个新的 : 等等......就像进程的二叉树......

So every instance of : starts two new : and so on... Like a binary tree of processes...

用纯 C 语言编写,即:

Written in plain C that is:

fork();
fork();

这篇关于Bash 命令 :(){ :|:&};: 将产生进程导致内核死亡.你能解释一下语法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆