No. There are just too many ways to write a fork-bomb.
The evil fork-bomb writer will just try again with a different function name. Or other alterations until his fork-bomb succeeds.
The inadvertent fork-bomb writer won't produce the canonical fork-bomb in the first place.
It's actually rather easy to become an inadvertent fork-bomb writer yourself. For instance, you could just use recursive make
with an external, unchecked cd
, combining it with the -j
option and non-existing subdirectories -- a real example I've stumbled upon once.
You cannot safeguard against all possibilities, and most certainly not against a determined attacker. All you will achieve is to increase the complexity of your system.
a(){ a|a& };a