Skip to main content

sys_brk

Function sys_brk 

Source
pub fn sys_brk(addr: u64) -> Result<u64, SyscallError>
Expand description

SYS_BRK (102): set or query the program break (top of heap).

Calling convention (matches Linux):

addrBehaviour
0Query — return current break unchanged.
> current_brkExtend heap; new pages are zero-filled RW anonymous.
< current_brkShrink heap; backing pages are freed.
< BRK_BASEInvalid — return current break unchanged (Linux compat).

On any error (OOM, out-of-range) the unchanged break is returned rather than a negative code — this is the Linux brk(2) contract.