grant
| Number | 0x23 |
|---|---|
| Signature | (handle, pid) -> slot or -err |
| Group | handles |
| Since | 1.0 |
Copy a handle to another process. This is the generic capability-transfer primitive. The source keeps its handle and the object’s refcount rises since this is a copy, not a move.
## Pitfalls
A received handle is non-grantable; only init can re-export. A capability therefore moves one hop from its origin, where origins are the kernel and whatever process created the object. The grantee gets no notification. Its table changes underneath it, so the granter must send the returned slot index over IPC.
Arguments
| Register | Name | Description |
|---|---|---|
r0 | handle | Handle to transfer |
r1 | pid | PID of the receiving process |
Returns
The handle index in the grantee's table.
Errors
| Code | Condition |
|---|---|
ERR_BADHANDLE | Source handle names no live entry |
ERR_BADARG | No calling thread context |
ERR_NOMEM | Grantee's handle table is full |
ERR_DEAD | Grantee process is dead, or port/ntfn is dead and the handle was cleaned up |
ERR_NOENT | Target PID is invalid |
ERR_NOPERM | Handle is not grantable, target is the caller, or handle is a REPLY or TASK type |