grant

Number0x23
Signature(handle, pid) -> slot or -err
Grouphandles
Since1.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

RegisterNameDescription
r0handleHandle to transfer
r1pidPID of the receiving process

Returns

The handle index in the grantee's table.

Errors

CodeCondition
ERR_BADHANDLESource handle names no live entry
ERR_BADARGNo calling thread context
ERR_NOMEMGrantee's handle table is full
ERR_DEADGrantee process is dead, or port/ntfn is dead and the handle was cleaned up
ERR_NOENTTarget PID is invalid
ERR_NOPERMHandle is not grantable, target is the caller, or handle is a REPLY or TASK type

See also