pub unsafe extern "C" fn AIBinder_getCallingPid() -> pid_t
Expand description
This returns the calling PID assuming that this thread is called from a thread that is processing a binder transaction (for instance, in the implementation of AIBinder_Class_onTransact).
This can be used with higher-level system services to determine the caller’s identity and check permissions. However, when doing this, one should be aware of possible TOCTOU problems when the calling process dies and is replaced with another process with elevated permissions and the same PID.
Warning: oneway transactions do not receive PID. Even if you expect a transaction to be synchronous, a misbehaving client could send it as a synchronous call and result in a 0 PID here. Additionally, if there is a race and the calling process dies, the PID may still be 0 for a synchronous call.
Available since API level 29.
\return calling pid or the current process’s PID if this thread isn’t processing a transaction. If the transaction being processed is a oneway transaction, then this method will return 0.