# File common/lib/symbiosis/utils.rb, line 449 def lock(fh) raise ArgumentError, "Expected a file handle not a #{fh.class}" unless fh.is_a?(File) raise ArgumentError, "File handle #{fh} is closed" if fh.closed? # flock_struct = [Fcntl::F_WRLCK, IO::SEEK_SET, 0, 0, 0]) # fh.fcntl(Fcntl::F_SETLK, flock_struct.pack("s2L2i*")) if fh.flock(File::LOCK_EX | File::LOCK_NB) return 0 else raise Errno::EAGAIN end rescue SystemCallError => err raise Errno::ENOLCK, "Unable to acquire lock -- #{err.to_s}" end