Skip to content

Instantly share code, notes, and snippets.

@rday
Last active July 8, 2016 02:07
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/cb7957b871369c99bc5b2dff601d883d to your computer and use it in GitHub Desktop.
Save rday/cb7957b871369c99bc5b2dff601d883d to your computer and use it in GitHub Desktop.
/**
* Verify that single thread, unshared file descriptor tables are freed
*/
#include <stdio.h>
#include <unistd.h>
void dupfds()
{
int i, fd;
int fds[128];
for (i=0; i<128; i++) {
fds[i] = dup(2);
if (fds[i]<0) {
perror("dup");
}
}
for (i=0; i<128; i++) {
close(fds[i]);
}
}
int main()
{
dupfds();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment