Ruby Issue Tracking System: Issueshttps://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112009-03-15T09:16:36ZRuby Issue Tracking System
Redmine Ruby master - Feature #1291 (Closed): O_CLOEXEC flag missing for Kernel::openhttps://redmine.ruby-lang.org/issues/12912009-03-15T09:16:36Zdavidroyalmartin (David Martin)dmartin@cs.bc.edu
<p>=begin<br>
Linux has a the most useful O_CLOEXEC flag for open() that sets the CLOEXEC flag on the new file descriptor.</p>
<p>You can currently set the CLOEXEC flag on an open file descriptor using IO::fcntl(), but note that this does <em>not</em> work in a multithreaded program: If one thread does open/fcntl while another does an exec, there is a race condition that could produce a file descriptor leak. The only safe way to open a file with the CLOEXEC flag set in general (as far as I know) is to use the O_CLOEXEC flag to open().<br>
=end</p>