0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ForkBombとその対処

Last updated at Posted at 2012-10-11
fork_bomb.c
# include <unistd.h>

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

一番シンプルな形だとこんな形。
ひたすらForkしてメモリを食いつぶしたりプロセステーブルを食いつぶす。
だいたいの場合はこのままマシンごと落ちたり固まるものだけど、MacだとForkBombを受けても生き残るケースがある。
ForkBombを「間違って」起動してしまった場合には慌てず騒がずシェルからForkBombをkillallする。
ただし、普通にkillallを叩こうとしてもプロセステーブルがいっぱいなのでforkできないと怒られる。
ので、exec killallを叩く訳だけど、やっぱりそれもだめ。
killallが殺していくかたわらForkBombが倍々ゲームで増えて行くのでまたすぐプロセステーブルが埋まってしまう。
ForkBombが起動してしまったら、まず、 exec killall -s SIGSTOP ForkBomb を叩いて一旦停止。
それから別のシェルで exec killlall -s SIGKILL ForkBomb で殺す。
シェルを2個以上開いていなかったらご愁傷さまかも。
念のため、シェルが余っているようなら、1回目のkillallを叩いた後にもう一回 exec killall -s SIGSTOP ForkBomb させておくとなお安心。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?