Visit Our UNIX and Linux User Community

Linux and UNIX Man Pages

Test Your Knowledge in Computers #30
Difficulty: Medium
Microsoft was founded in 1971.
True or False?
Linux & Unix Commands - Search Man Pages

brk(2) [plan9 man page]

BRK(2)								System Calls Manual							    BRK(2)

brk, sbrk - change memory allocation SYNOPSIS
#include <u.h> #include <libc.h> int brk(void *addr) void* sbrk(ulong incr) DESCRIPTION
Brk sets the system's idea of the lowest bss location not used by the program (called the break) to addr rounded up to the next multiple of 8 bytes. Locations not less than addr and below the stack pointer may cause a memory violation if accessed. In the alternate function sbrk, incr more bytes are added to the program's data space and a pointer to the start of the new area is returned. Rounding occurs as with brk. When a program begins execution via exec the break is set at the highest location defined by the program and data storage areas. Ordinar- ily, therefore, only programs with growing data areas need to use brk. A call to sbrk with a zero argument returns the lowest address in the dynamic segment. SOURCE
/sys/src/libc/9sys/sbrk.c SEE ALSO
intro(2), malloc(2), segattach(2), segbrk(2) DIAGNOSTICS
These functions set errstr. The error return from sbrk is (void*)-1. BRK(2)

Check Out this Related Man Page

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

brk, sbrk - change data segment size SYNOPSIS
#include <unistd.h> int brk(void *end_data_segment); void *sbrk(ptrdiff_t increment); DESCRIPTION
brk sets the end of the data segment to the value specified by end_data_segment, when that value is reasonable, the system does have enough memory and the process does not exceed its max data size (see setrlimit(2)). sbrk increments the program's data space by increment bytes. sbrk isn't a system call, it is just a C library wrapper. Calling sbrk with an increment of 0 can be used to find the current location of the program break. RETURN VALUE
On success, brk returns zero, and sbrk returns a pointer to the start of the new area. On error, -1 is returned, and errno is set to ENOMEM. CONFORMING TO
BSD 4.3 brk and sbrk are not defined in the C Standard and are deliberately excluded from the POSIX.1 standard (see paragraphs B. and B.8.3.3). SEE ALSO
execve(2), getrlimit(2), malloc(3) Linux 0.99.11 1993-07-21 BRK(2)

Featured Tech Videos