This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients Christophe.Devriese, gregory.p.smith, nadeem.vawda, neologix, pitrou, vstinner
Date 2013-01-08.23:26:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1357687560.69.0.936289086978.issue12107@psf.upfronthosting.co.za>
In-reply-to
Content
"Note that I don't like the idea of falling back to FD_CLOEXEC since
it's not atomic, and some people might rely on this."

There is a similar question (atomic or best effort) for the #16860 issue. It looks like more people prefer the best effort option.

IMO most people prefer to use the best available method to set the close-on-exec flag, but doesn't really care if the method is not atomic (and the OS doesn't provide an atomic function).

If someone cannot accept the best effort option: I guess that it is still possible to override TCPServer constructor to ensure that the action is atomic.

"It would already be a nice piece of progress if you could request the
SO_CLOEXEC (with fallback to FD_CLOEXEC), say, in the constructor, or even with a module variable."

Yes, close-on-exec flag should be configurable, as TCPServer.allow_reuse_address for example. I like the class attribute, something like TCPServer.close_on_exec, False by default, for example.

--

"I realize this bugreport cannot fix 35 years of a bad design decision in linux."

Well... Ruby made a brave choice :-) Ruby (2.0?) does set
close-on-exec flag on *ALL file descriptors (except 0, 1, 2) *by
default*:
http://bugs.ruby-lang.org/issues/5041

This change solves the problem of having to close all file descriptor
after a fork to run a new program (see closed Python issues #11284 and
#8052)... if you are not using C extensions creating file descriptors?

Ruby applications relying on passing FD to child processes have to
explicitly disable close-on-exec the flag: it was done in Unicorn for
example.

"But we can't simply change the default to FD_CLOEXEC, for two reasons:
- we can't silently change the Unix semantics
- this is going to break some applications: for example, FD inherited across exec is used by super servers such as inetd, and there are others very legitimate uses"

Yes, changing the default value of the flag (enable close-on-exec by default) will break some applications. But if we chose to do it, developers of these applications can still disable close-on-exec (because the option must be configurable) to fix their application for Python 3.4.
History
Date User Action Args
2013-01-08 23:26:00vstinnersetrecipients: + vstinner, gregory.p.smith, pitrou, nadeem.vawda, neologix, Christophe.Devriese
2013-01-08 23:26:00vstinnersetmessageid: <1357687560.69.0.936289086978.issue12107@psf.upfronthosting.co.za>
2013-01-08 23:26:00vstinnerlinkissue12107 messages
2013-01-08 23:26:00vstinnercreate