问题
,_,( ){ ,_,| ,_,&};,_,
I am not sure what it means...
Looks like a bash command but it might be s bash shell directive or something would appreciate if someone can help understand this. It killed my bash when I ran it.
回答1:
It's a fork bomb; it will spawn a (potentially) infinite number of processes, until your system runs out of resources (and usually becomes inoperable).
It defines the function named ,_,, which runs itself (recursion), and piping the output to itself. The last ,_, is needed to start off the thing.
Formatted, and with ,_, replaced by fun, it looks like:
fun() {
fun | fun &
};
fun
Every invocation of fun will spawn 2 more invocations of fun. The & starts the processes in the background (rate of process increase is exponential).
It's a variant of the better known :() { :|: & };:
There are ways to prevent your system from crashing, though; for example in Linux you can edit /etc/security/limit.conf & set the maximum number of processes for a user. Other systems have other (usually similar) methods.
Running a fork bomb and crashing your system seems to be something of a rite of passage for UNIX users; it teaches you:
- The importance of imposing resource limits of processes;
- that copying & executing commands you do not understand from untrusted sources (eg. the internet) is not a good idea
来源:https://stackoverflow.com/questions/27197785/what-does-this-command-does-in-bash