WvStreams
crashtest-nofd.cc
1 #include "wvcrash.h"
2 #include <sys/types.h>
3 #include <sys/socket.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <fcntl.h>
7 
8 int main(int argc, char **argv)
9 {
10  wvcrash_setup(argv[0], "BLAHBLAH");
11 
12  int fd, count = 0;
13  while ((fd = socket(PF_INET, SOCK_STREAM, 0)) >= 0)
14  {
15  fcntl(fd, F_SETFD, 0); // *not* close-on-exec
16  count++;
17  }
18  printf("Got %d sockets.\n", count);
19 
20  // all fds are now in use; let's see if wvcrash can handle it!
21 
22  abort();
23 
24  return 0;
25 }