xpc_connection_get_pid(_:)
Returns the PID of the remote peer.
Declaration
func xpc_connection_get_pid(_ connection: xpc_connection_t) -> pid_tParameters
- connection:
The connection object which is to be examined.
Return Value
The PID of the remote peer.
Discussion
A given PID is not guaranteed to be unique across an entire boot cycle. Great care should be taken when dealing with this information, as it can go stale after the connection is established. macOS recycles PIDs, and therefore another process could spawn and claim the PID before a message is actually received from the connection.
XPC will deliver an error to your event handler if the remote process goes away, but there are no guarantees as to the timing of this notification’s delivery either at the kernel layer or at the XPC layer.
See Also
Remote peer information
xpc_connection_get_name(_:)xpc_connection_get_euid(_:)xpc_connection_get_egid(_:)xpc_connection_get_asid(_:)xpc_connection_set_peer_entitlement_exists_requirement(_:_:)xpc_connection_set_peer_entitlement_matches_value_requirement(_:_:_:)xpc_connection_set_peer_lightweight_code_requirement(_:_:)xpc_connection_set_peer_platform_identity_requirement(_:_:)xpc_connection_set_peer_team_identity_requirement(_:_:)xpc_connection_set_peer_code_signing_requirement(_:_:)