Created
May 8, 2017 20:03
-
-
Save insom/7f60e9bb55c287e514228b0b18e530da to your computer and use it in GitHub Desktop.
Let's make a lot of threads!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc -D_GNU_SOURCE=1 -std=c99 a.c | |
#include <sched.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
int f(void *p) { | |
sleep(2); | |
} | |
void main(void) { | |
for(int i = 0; i < 32770; i++) { | |
void *s = malloc(256); // stack size | |
int r = clone(f, s, 0, NULL); | |
if(r < 0) { | |
printf("The number was: %d\n", i); | |
perror(NULL); | |
exit(0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment