Message179402
| Author |
vstinner |
| Recipients |
Christophe.Devriese, gregory.p.smith, nadeem.vawda, neologix, pitrou, vstinner |
| Date |
2013年01月09日.00:07:16 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1357690037.94.0.786606736501.issue12107@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
socketserver_close_on_exec.patch:
- Add TCPServer.close_on_exec class attribute: True by default if the fcntl module is present, False otherwise
- Use SOCK_CLOEXEC if present, fcntl() + FD_CLOEXEC otherwise
Even if SOCK_CLOEXEC is present, fcntl() is used to check the flag "works" (if FD_CLOEXEC was set). If SOCK_CLOEXEC works, fcntl() will not be called anymore, otherwise we fall back to fcntl() + FD_CLOEXEC. I implemented this fallback for Linux older than 2.6.27. I don't know if SOCK_CLOEXEC is simply ignored, as Linux did for O_CLOEXEC, but I don't have such old Linux version to test.
I chose to set close-on-exec flag *by default*. If we chose to disable it by default, the following changes should be done on my patch:
- TCPServer.close_on_exec : "close_on_exec = (fcntl is not None)" => "close_on_exec = False"
- SimpleXMLRPCServer: add close_on_exec class attribute, "close_on_exec = (fcntl is not None)" (and restore try/except ImportError for fcntl) |
|