Name

flock

flock options fileId [start] [length] [origin]

Place a lock on all or part of the file open with identifier fileId. The file data is locked from the beginning of byte offset start for a length of length bytes. The default start position is the start of file, and the default length is to the end of file. If the file is currently locked, the command waits until it is unlocked before returning.

The value of origin indicates the offset for the data locked and is one of the strings start (relative to start of file, the default), current (relative to the current access position), or end (relative to end of file, extending backward).

This command is not supported on Windows 95/98. Also see funlock.

Options

-read

Place a read lock on the file.

-write

Place a write lock on the file.

-nowait

Do not block if lock cannot be obtained. Return 1 if the file could be locked, or 0 if it could not.

Get Tcl/Tk in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.