Close all sockets before fork()

This commit is contained in:
Jan Kaluza 2012-10-30 12:09:23 +01:00
parent df32761194
commit 700ce99187

View file

@ -185,6 +185,11 @@ static unsigned long exec_(const std::string& exePath, const char *host, const c
pid_t pid = fork();
if ( pid == 0 ) {
setsid();
// close all files
int maxfd=sysconf(_SC_OPEN_MAX);
for(int fd=3; fd<maxfd; fd++) {
close(fd);
}
// child process
errno = 0;
int ret = execv(argv[0], argv);