4.4BSD/usr/share/man/cat2/sbrk.0

Compare this file to the similar file:
Show the results in this format:

BRK(2)                      BSD Programmer's Manual                     BRK(2)

NNAAMMEE
     bbrrkk, ssbbrrkk - change data segment size

SSYYNNOOPPSSIISS
     ##iinncclluuddee <<ssyyss//ttyyppeess..hh>>

     _c_h_a_r
     **bbrrkk(_c_o_n_s_t _c_h_a_r _*_a_d_d_r);

     _c_h_a_r _*
     **ssbbrrkk(_i_n_t _i_n_c_r);

DDEESSCCRRIIPPTTIIOONN
     TThhee bbrrkk aanndd ssbbrrkk ffuunnccttiioonnss aarree hhiissttoorriiccaall ccuurriioossiittiieess lleefftt oovveerr ffrroomm eeaarr--
     lliieerr ddaayyss bbeeffoorree tthhee aaddvveenntt ooff vviirrttuuaall mmeemmoorryy mmaannaaggeemmeenntt..   The bbrrkk()
     function sets the break or lowest address of a process's data segment
     (unilitialized data) to _a_d_d_r (immediately above bss).  Data addressing is
     restricted between _a_d_d_r and the lowest stack pointer to the stack seg-
     ment.  Memory is allocated by _b_r_k in page size pieces; if _a_d_d_r is not
     evenly divisible by the system page size, it is increased to the next
     page boundary.

     The current value of the program break is reliably returned by
     ``sbrk(0)'' (see also end(3)).  The getrlimit(2) system call may be used
     to determine the maximum permissible size of the _d_a_t_a segment; it will
     not be possible to set the break beyond the _r_l_i_m___m_a_x value returned from
     a call to getrlimit,  e.g.  ``qetext + rlp->rlim_max.'' (see end(3) for
     the definition of _e_t_e_x_t).

RREETTUURRNN VVAALLUUEESS
     BBrrkk returns a pointer to the new end of memory if successful; otherwise
     -1 with _e_r_r_n_o set to indicate why the allocation failed.  The ssbbrrkk re-
     turns a pointer to the base of the new storage if successful; otherwise
     -1 with _e_r_r_n_o set to indicate why the allocation failed.

EERRRROORRSS
     Sbrk will fail and no additional memory will be allocated if one of the
     following are true:

     [ENOMEM]  The limit, as set by setrlimit(2),  was exceeded.

     [ENOMEM]  The maximum possible size of a data segment (compiled into the
               system) was exceeded.

     [ENOMEM]  Insufficient space existed in the swap area to support the ex-
               pansion.

SSEEEE AALLSSOO
     execve(2),  getrlimit(2),  malloc(3),  end(3)

BBUUGGSS
     Setting the break may fail due to a temporary lack of swap space.  It is
     not possible to distinguish this from a failure caused by exceeding the
     maximum size of the data segment without consulting getrlimit.

HHIISSTTOORRYY
     A bbrrkk function call appeared in Version 7 AT&T UNIX.

4th Berkeley Distribution        June 4, 1993                                1