def _setCloseOnExec(fd):
        """
        Make a file descriptor close-on-exec.
        """
        flags = fcntl.fcntl(fd, fcntl.F_GETFD)
        flags = flags | fcntl.FD_CLOEXEC
        fcntl.fcntl(fd, fcntl.F_SETFD, flags)

        Make a file descriptor close-on-exec.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/internet/fdesc.py