PATCH: Handle missing FD_CLOEXEC

Mark Mitchell mark at codesourcery.com
Fri Sep 12 18:23:00 UTC 2003


The Python 2.2 RPM shipped with Red Hat 7.3 does not define
fcntl.FD_CLOEXEC.

This patch implements a workaround.

-- 
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery.com
-------------- next part --------------
2003-09-12  Mark Mitchell  <mark at codesourcery.com>

	* qm/executable.py (Executable._MakeCloseOnExec): Deal with
	missing fcntl.FD_CLOEXEC.

Index: qm/executable.py
===================================================================
RCS file: /home/sc/Repository/qm/qm/executable.py,v
retrieving revision 1.17
diff -c -5 -p -r1.17 executable.py
*** qm/executable.py	15 Aug 2003 09:05:23 -0000	1.17
--- qm/executable.py	12 Sep 2003 18:13:02 -0000
*************** class Executable(object):
*** 317,328 ****
  
          UNIX only."""
  
          assert sys.platform != "win32"
  
!         old_flags = fcntl.fcntl(fd, fcntl.F_GETFD)
!         fcntl.fcntl(fd, fcntl.F_SETFD, old_flags | fcntl.FD_CLOEXEC)
  
  
      def __CreateCommandLine(self, arguments):
          """Return a string giving the process command line.
  
--- 317,335 ----
  
          UNIX only."""
  
          assert sys.platform != "win32"
  
!         flags = fcntl.fcntl(fd, fcntl.F_GETFD)
!         try:
!             flags |= fcntl.FD_CLOEXEC
!         except AttributeError:
!             # The Python 2.2 RPM shipped with Red Hat Linux 7.3 does
!             # not define FD_CLOEXEC.  Fortunately, FD_CLOEXEC is 1 on
!             # every UNIX system.
!             flags |= 1
!         fcntl.fcntl(fd, fcntl.F_SETFD, flags)
  
  
      def __CreateCommandLine(self, arguments):
          """Return a string giving the process command line.
  


More information about the qmtest mailing list