flock (locking_constant) Locks or unlocks afile according to locking_constant. : flock « File Directory « Ruby






flock (locking_constant) Locks or unlocks afile according to locking_constant.


# Returns false if File::LOCK_NB is specified and the operation would otherwise have blocked. 
# Not available on all platforms. 

puts File.new("testfile").flock(File::LOCK_UN)   

# Lock code constants 

# LOCK_EX        Exclusive lock. 
# LOCK_NB        Don't block when locking. 
# LOCK_SH        Shared lock. 
# LOCK_UN        Unlock. 

 








Related examples in the same category