def get_socket_inherit(socket):
 try:
  if iswindows:
   import win32api, win32con
   flags = win32api.GetHandleInformation(socket.fileno())
   return bool((flags & win32con.HANDLE_FLAG_INHERIT))
  else:
   import fcntl
   flags = fcntl.fcntl(socket.fileno(), fcntl.F_GETFD)
   return (not bool((flags & fcntl.FD_CLOEXEC)))
 except:
  import traceback
  traceback.print_exc()

def get_socket_inherit ( socket ) : try : if iswindows : import win32api , win32con flags = win32api . GetHandleInformation ( socket . fileno ( ) ) return bool ( ( flags & win32con . HANDLE_FLAG_INHERIT ) ) else : import fcntl flags = fcntl . fcntl ( socket . fileno ( ) , fcntl . F_GETFD ) return ( not bool ( ( flags & fcntl . FD_CLOEXEC ) ) ) except : import traceback traceback . print_exc ( )
returns true if the socket has been set to allow inheritance across forks and execs to child processes .