On Nov 14, 2007, at 10:06 AM, rae l wrote:

I noticed the latest changeset r1474 on
http://svn.osdl.org/openais/trunk/exec/main.c is:

   Patch to close all open files on background run operation.

But as far as I know, some openais plugin such as cman_tool of
redhat-cluster-suite have used PIPE number in environment as its
InterProcessCommunication,

it's internal processing is:
cman_tool create a pipe with pipe systemcall, and put the write pipe
number in an environment variable CMAN_PIPE, clear its close-on-exec
flag bit, fork a subprocess to exec aisexec, then aisexec will execute
/usr/libexec/lcrso/service_cman.lcrso, this plugin will read
cman_tool's write pipe number from the environment, and then write
something to it.

But after r1474 of openais-trunk, this style of IPC will break:
because CMAN_PIPE number usually a little number, below the
oflimits.rlim_cur, that will be closed while aisexec executing, the
service_cman.lcrso would get a broken pipe.

I tried to install cluster-suite from redhat's CVS HEAD and openais
from openais-trunk, and they run uncorrectly indeed.

I don't know why all filedescriptor below oflimits.rlim_cur should be
closed as said in r1474, if just to daemon a process, my suggestion is
just to close all tty file descriptor, and the patch is here, it could
make cman_tool work well:

Steve has a patch (I dont think he's committed it yet) that gets rid of my loop and just does:
                        close (0);
                        close (1);
                        close (2);

Which achieves the desired result and doesn't close anyone's pipes :-)



Index: trunk/exec/main.c
===================================================================
--- trunk/exec/main.c   (revision 1480)
+++ trunk/exec/main.c   (working copy)
@@ -288,7 +288,8 @@
         */
        getrlimit(RLIMIT_NOFILE, &oflimits);
        for (lpc = 0; lpc < oflimits.rlim_cur; lpc++) {
-               close(lpc);
+               if (isatty(lpc))
+                       close(lpc);
        }

        /*

--
Denis Cheng
Linux Application Developer
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to