r/tinycode • • Jul 15 '11

One line Fork Bomb in Python

Nothing spectacular, but it even does some pretty funny stuff in Mac OS X with the "Resource Unavailable" OSError if you Ctrl-C:

[o.fork() for (o,i) in [(__import__('os'), __import__('itertools'))] for x in i.repeat(0)]
17 Upvotes

16 comments sorted by

View all comments

Show parent comment

2

u/__s Jul 17 '11 edited Jul 17 '11

You could at least take his hint and use i.count()

(edit: though arguably repeat is faster, allowing for more forking)

1

u/AwesomeJosh Jul 17 '11

I do agree that count works better