source: trunk/minix/man/man2/brk.2@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 2.0 KB
Line 
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5.\" @(#)brk.2 6.3 (Berkeley) 5/22/86
6.\"
7.TH BRK 2 "May 22, 1986"
8.UC 4
9.SH NAME
10brk, sbrk \- change data segment size
11.SH SYNOPSIS
12.nf
13#include <unistd.h>
14.PP
15.ft B
16int brk(char *\fIaddr\fP)
17.PP
18.ft B
19char *sbrk(int \fIincr\fP)
20.fi
21.SH DESCRIPTION
22.B Brk
23sets the system's idea of the lowest data segment
24location not used by the program (called the break)
25to
26.IR addr .
27Locations greater than
28.I addr
29and below the stack pointer
30are not in the address space and will thus
31cause a memory violation if accessed.
32.PP
33In the alternate function
34.BR sbrk ,
35.I incr
36more bytes are added to the
37program's data space and a pointer to the
38start of the new area is returned.
39.PP
40When a program begins execution via
41.B execve
42the break is set at the
43highest location defined by the program
44and data storage areas.
45Ordinarily, therefore, only programs with growing
46data areas need to use
47.BR sbrk .
48.SH "RETURN VALUE
49The address of the new break is returned if
50.B brk
51succeeds;
52.B \-1
53if the program requests more
54memory than the system limit.
55.B Sbrk
56returns
57.B \-1
58if the break could not be set.
59.SH ERRORS
60.B Sbrk
61will fail and no additional memory will be allocated if
62one of the following are true:
63.TP 15
64[ENOMEM]
65The maximum possible size of a data segment (as set by
66.BR chmem (1))
67was exceeded.
68.TP 15
69[ENOMEM]
70Insufficient virtual memory space existed
71to support the expansion. (Minix-vmd)
72.SH "SEE ALSO"
73.BR chmem (1),
74.BR execve (2),
75.BR malloc (3),
76.BR end (3).
77.SH NOTES
78Minix-vmd rounds a small data segment limit up to 3 megabytes.
79.SH BUGS
80Setting the break may fail due to a temporary lack of
81virtual memory under Minix-vmd. It is not possible to distinguish this
82from a failure caused by exceeding the maximum size of
83the data segment.
84
85.\"
86.\" $PchId: brk.2,v 1.2 2000/08/11 20:05:51 philip Exp $
Note: See TracBrowser for help on using the repository browser.