<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "System",
  "identifier" : "/documentation/System/FileDescriptor/OpenOptions/sharedLock",
  "metadataVersion" : "0.1.0",
  "role" : "Type Property",
  "symbol" : {
    "kind" : "Type Property",
    "modules" : [
      "System"
    ],
    "preciseIdentifier" : "s:6System14FileDescriptorV11OpenOptionsV10sharedLockAEvpZ"
  },
  "title" : "sharedLock"
}
-->

# sharedLock

Indicates that opening the file
atomically obtains a shared lock on the file.

```
static var sharedLock: FileDescriptor.OpenOptions { get }
```

## Discussion

Setting this option or the [`exclusiveLock`](/documentation/System/FileDescriptor/OpenOptions/exclusiveLock) option
obtains a lock with `flock(2)` semantics.
If you’re creating a file using the [`create`](/documentation/System/FileDescriptor/OpenOptions/create) option,
the request for the lock always succeeds
except on file systems that don’t support locking.

The corresponding C constant is `O_SHLOCK`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)