Skip to content

Instantly share code, notes, and snippets.

@rday
Created July 8, 2016 02:06
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 rday/7229c97de0f97f22048357b9c617bc7e to your computer and use it in GitHub Desktop.
Save rday/7229c97de0f97f22048357b9c617bc7e to your computer and use it in GitHub Desktop.
/**
* 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