From 4428ca3661ac9fdff42993a02044b398a317bbd5 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Wed, 16 Jul 2003 23:22:22 +0000 Subject: [PATCH] fixed base to use close on exec options whenever creating a socket on posix compliant systems --- src/libCom/osi/os/posix/osdProcess.c | 46 +++------------------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/src/libCom/osi/os/posix/osdProcess.c b/src/libCom/osi/os/posix/osdProcess.c index 44a6ade5c..da302207b 100644 --- a/src/libCom/osi/os/posix/osdProcess.c +++ b/src/libCom/osi/os/posix/osdProcess.c @@ -22,7 +22,6 @@ #include #include #include -#include /* OPEN_MAX defined here */ #include #include #include @@ -59,37 +58,6 @@ epicsShareFunc osiGetUserNameReturn epicsShareAPI osiGetUserName (char *pBuf, un } } -/* - * maxPosixFD () - * - * attempt to determine the maximum file descriptor - * on all posix systems - */ -static int maxPosixFD ( ) -{ - int max; -# if ! defined (OPEN_MAX) - static const int bestGuess = 1024; -# endif - -# if defined (_SC_OPEN_MAX) /* posix */ - max = sysconf (_SC_OPEN_MAX); - if (max<0) { -# if defined (OPEN_MAX) - max = OPEN_MAX; -# else - max = bestGuess; -# endif - } -# elif defined (OPEN_MAX) /* posix */ - max = OPEN_MAX; -# else - max = bestGuess; -# endif - - return max; -} - epicsShareFunc osiSpawnDetachedProcessReturn epicsShareAPI osiSpawnDetachedProcess (const char *pProcessName, const char *pBaseExecutableName) { @@ -114,17 +82,11 @@ epicsShareFunc osiSpawnDetachedProcessReturn epicsShareAPI osiSpawnDetachedProce } /* - * close all open files except for STDIO so they will not - * be inherited by the spawned process + * since all epics sockets are created with the FD_CLOEXEC + * option then we no-longer need to blindly close all open + * files here. */ - maxfd = maxPosixFD (); - for (fd = 0; fd<=maxfd; fd++) { - if (fd==STDIN_FILENO) continue; - if (fd==STDOUT_FILENO) continue; - if (fd==STDERR_FILENO) continue; - close (fd); - } - + /* * overlay the specified executable */