*** src/Ice/Service.cpp.orig Fri Jan 5 16:20:52 2007 --- src/Ice/Service.cpp Fri Jan 5 17:22:55 2007 *************** *** 27,32 **** --- 27,33 ---- # include # include # include + # include #endif using namespace std; *************** *** 1617,1624 **** } } ! fd_set fdsToClose; ! int fdMax = 0; if(_closeFiles) { // --- 1618,1624 ---- } } ! std::list fdsToClose; if(_closeFiles) { // *************** *** 1627,1634 **** // have an opportunity to use stdin/stdout/stderr if necessary. This also // conveniently allows the Ice.PrintProcessId property to work as expected. // ! FD_ZERO(&fdsToClose); ! fdMax = static_cast(sysconf(_SC_OPEN_MAX)); if(fdMax <= 0) { SyscallException ex(__FILE__, __LINE__); --- 1627,1633 ---- // have an opportunity to use stdin/stdout/stderr if necessary. This also // conveniently allows the Ice.PrintProcessId property to work as expected. // ! int fdMax = static_cast(sysconf(_SC_OPEN_MAX)); if(fdMax <= 0) { SyscallException ex(__FILE__, __LINE__); *************** *** 1638,1649 **** for(int i = 0; i < fdMax; ++i) { ! if(fcntl(i, F_GETFL) != -1) { ! FD_SET(i, &fdsToClose); } } - FD_CLR(fds[1], &fdsToClose); // Don't close the write end of the pipe. } // --- 1637,1647 ---- for(int i = 0; i < fdMax; ++i) { ! if(fcntl(i, F_GETFL) != -1 && i != fds[1]) // except write end of pipe { ! fdsToClose.push_back(i); } } } // *************** *** 1669,1687 **** string stdOut = properties->getProperty("Ice.StdOut"); string stdErr = properties->getProperty("Ice.StdErr"); ! for(int i = 0; i < fdMax; ++i) { // // NOTE: Do not close stdout if Ice.StdOut is defined. Likewise for Ice.StdErr. // ! if((i == 1 && !stdOut.empty()) || (i == 2 && !stdErr.empty())) { continue; } ! if(FD_ISSET(i, &fdsToClose)) ! { ! close(i); ! } } // --- 1667,1686 ---- string stdOut = properties->getProperty("Ice.StdOut"); string stdErr = properties->getProperty("Ice.StdErr"); ! while (!fdsToClose.empty()) { // // NOTE: Do not close stdout if Ice.StdOut is defined. Likewise for Ice.StdErr. // ! int fd = fdsToClose.back(); ! fdsToClose.pop_back(); ! ! if((fd == 1 && !stdOut.empty()) || (fd == 2 && !stdErr.empty())) { continue; } ! ! close(fd); } //