Skip to content

Instantly share code, notes, and snippets.

@perillamint
Created April 3, 2015 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perillamint/964236c58bdb7678a038 to your computer and use it in GitHub Desktop.
Save perillamint/964236c58bdb7678a038 to your computer and use it in GitHub Desktop.
forklimit count
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
int main (int argc, char **argv) {
int i;
int res;
printf("Forkbomb!\n");
for(i = 0; res = fork(); i++) {
if(res == -1) {
printf("Fork failed! %s\n", strerror(errno));
printf("Fork count: %d\n", i);
exit(0);
}
}
if(res == 0) {
sleep(1);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment