Class: Preforker::Util
- Inherits:
-
Object
- Object
- Preforker::Util
- Defined in:
- lib/preforker/util.rb
Class Method Summary collapse
- .is_log?(fp) ⇒ Boolean
-
.tmpio ⇒ Object
creates and returns a new File object.
Class Method Details
.is_log?(fp) ⇒ Boolean
17 18 19 20 21 22 23 24 |
# File 'lib/preforker/util.rb', line 17 def self.is_log?(fp) append_flags = File::WRONLY | File::APPEND ! fp.closed? && fp.sync && fp.path[0] == ?/ && (fp.fcntl(Fcntl::F_GETFL) & append_flags) == append_flags end |
.tmpio ⇒ Object
creates and returns a new File object. The File is unlinked immediately, switched to binary mode, and userspace output buffering is disabled
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/preforker/util.rb', line 29 def self.tmpio fp = begin TmpIO.open("#{Dir::tmpdir}/#{rand}", File::RDWR|File::CREAT|File::EXCL, 0600) rescue Errno::EEXIST retry end File.unlink(fp.path) fp.binmode fp.sync = true fp end |