Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
proc
/
thread-self
/
root
/
proc
/
self
/
root
/
opt
/
ruby-2.7
/
usr
/
share
/
ri
/
2.7.0
/
system
/
File
/
//proc/thread-self/root/proc/self/root/opt/ruby-2.7/usr/share/ri/2.7.0/system/File/flock-i.ri
U:RDoc::AnyMethod[iI" flock:ETI"File#flock;TF:publico:RDoc::Markup::Document:@parts[ o:RDoc::Markup::Paragraph; [ I"ELocks or unlocks a file according to <i>locking_constant</i> (a ;TI"<logical <em>or</em> of the values in the table below). ;TI"FReturns <code>false</code> if File::LOCK_NB is specified and the ;TI"Boperation would otherwise have blocked. Not available on all ;TI"platforms.;To:RDoc::Markup::BlankLine o; ; [I"'Locking constants (in class File):;T@o:RDoc::Markup::Verbatim; [I">LOCK_EX | Exclusive lock. Only one process may hold an ;TI"< | exclusive lock for a given file at a time. ;TI"A----------+------------------------------------------------ ;TI";LOCK_NB | Don't block when locking. May be combined ;TI"; | with other lock options using logical or. ;TI"A----------+------------------------------------------------ ;TI"ALOCK_SH | Shared lock. Multiple processes may each hold a ;TI"@ | shared lock for a given file at the same time. ;TI"A----------+------------------------------------------------ ;TI"LOCK_UN | Unlock. ;T:@format0o; ; [I" Example:;T@o;; [I")# update a counter using write lock ;TI"@# don't use "w" because it truncates the file before lock. ;TI"=File.open("counter", File::RDWR|File::CREAT, 0644) {|f| ;TI" f.flock(File::LOCK_EX) ;TI" value = f.read.to_i + 1 ;TI" f.rewind ;TI" f.write("#{value}\n") ;TI" f.flush ;TI" f.truncate(f.pos) ;TI"} ;TI" ;TI"(# read the counter using read lock ;TI"$File.open("counter", "r") {|f| ;TI" f.flock(File::LOCK_SH) ;TI" p f.read ;TI"};T; 0: @fileI"file.c;T:0@omit_headings_from_table_of_contents_below0I"0file.flock(locking_constant) -> 0 or false ;T0[ I" (p1);T@7FI" File;TcRDoc::NormalClass00