skystrife / procxx

A simple process management library for C++ on UNIX platforms.
MIT License
143 stars 28 forks source link

Don't forget to close inherited file descriptors #18

Open tangxinfa opened 5 years ago

tangxinfa commented 5 years ago

fork ....

in child process

  int max_fd = getdtablesize();
  if (max_fd < 0) {
    max_fd = 1024;
  }
  int fd;
  for (fd = 3; fd <= max_fd; ++fd) {
    close(fd);
  }

exec ...