SHARE

Control file access

WSupported on Windows
USupported on Unix
VSupported on OpenVMS
NSupported in Synergy .NET
SHARE:share_spec

share_spec

One of the following identifiers or corresponding values: (n)

Q_EXCL_RW or 0

Allow only exclusive read and write access for the file. With this option set, other users cannot access the file.

Q_EXCL_RO or 1

Allow read-only access for the file. With this option set, other users can read but not write to the file.

Q_NO_EXCL or 2

Allow other users to both read and write to the file.

The SHARE qualifier specifies whether a file can be accessed by other users.

To achieve the exclusive access of Q_EXCL_RW and Q_EXCL_RO, the systems file permissions must allow write access to the file.

The default share_spec value depends on the mode in which the file was opened: If the file was opened in input or update mode, both read and write access is allowed by default (that is, Q_NO_EXCL or 2); however, if the file was opened in output or append mode, only exclusive access is allowed (that is, Q_EXCL_RW or 0).

On Unix, setting the LOCK:Q_NO_LOCK qualifier overrides an exclusively locked file that was opened using an exclusive SHARE qualifier (either Q_EXCL_RW or Q_EXCL_RO). Opening a file with Q_EXCL_RO generates a “File in use” error when another process has the same file open with Q_EXCL_RO, regardless of the OPEN mode.

On OpenVMS, opening a file Q_EXCL_RW minimizes lock activity.

The SHARE qualifier has no effect on an OPEN statement where the OPEN mode specified is either append (A) or output (O).