<!--
{
  "availability" : [
    "iOS: 17.4.0 -",
    "iPadOS: 17.4.0 -",
    "macCatalyst: 17.4.0 -",
    "macOS: 14.4.0 -",
    "tvOS: 17.4.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "System",
  "identifier" : "/documentation/System/Mach/Port/unguardAndRelinquish()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "System"
    ],
    "preciseIdentifier" : "s:6System4MachO4PortVAaC12ReceiveRightVRszrlE20unguardAndRelinquishs6UInt32VyF"
  },
  "title" : "unguardAndRelinquish()"
}
-->

# unguardAndRelinquish()

Remove guard and transfer ownership of the underlying port right to
the caller.

```
consuming func unguardAndRelinquish() -> mach_port_name_t
```

## Discussion

Returns the Mach port name representing the right.

This operation liberates the right from management by the Mach.Port,
and the underlying right will no longer be automatically deallocated.

After this function completes, the Mach.Port is destroyed and no longer
usable.

This function makes a syscall to remove the guard from
Mach.ReceiveRights. Use relinquish() to avoid the syscall and extract
the context value along with the port name.

---

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)