Created
July 8, 2016 02:06
-
-
Save rday/7229c97de0f97f22048357b9c617bc7e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Make sure that processes with multiple threads don't have old | |
* file descriptor tables freed. | |
*/ | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <pthread.h> | |
void *dupfds() | |
{ | |
int i, fd; | |
for (i=0; i<64; i++) { | |
fd = dup(2); | |
if (fd<0) { | |
perror("dup"); | |
} | |
} | |
pthread_exit(NULL); | |
} | |
int main() | |
{ | |
pthread_t threads[10]; | |
int i, res; | |
for (i=0;i<10;i++) { | |
res = pthread_create(&threads[i], NULL, dupfds, NULL); | |
} | |
pthread_exit(NULL); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment