'\"macro stdmacro
.if n .pH g2.plock @(#)plock	40.11 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} plock 2 "" "\&"
.if \nX=1 .ds x} plock 2 ""
.if \nX=2 .ds x} plock 2 "" "\&"
.if \nX=3 .ds x} plock "" "" "\&"
.TH \*(x}
.SH NAME
\f4plock\f1 \- lock into memory or unlock process, text, or data
.SH SYNOPSIS
\f4#include <sys/lock.h>\f1
.PP
\f4int plock(int op);\f1
.SH DESCRIPTION
\f4plock\fP
allows the calling process to lock into memory or unlock its text segment (text lock),
its data segment (data lock), or both its text and data segments (process lock).
Locked segments are immune to all routine swapping.
The effective user \s-1ID\s+1 of the calling process must be super-user to
use this call.
\f4plock\fP performs the function specified by
.IR op :
.RS
.TP 12
\f4PROCLOCK \f1
Lock text and data segments into memory (process lock).
.TP
\f4TXTLOCK \f1
Lock text segment into memory (text lock).
.TP
\f4DATLOCK \f1
Lock data segment into memory (data lock).
.TP
\f4UNLOCK \f1
Remove locks.
.RE
.PP
\f4plock\fP
fails and does not perform the requested operation if one or more of
the following are true:
.TP 15
\f4EPERM\fP
The effective user \s-1ID\s+1 of the calling process is not super-user.
.TP
\f4EINVAL\fP
.I op
is equal to
\f4PROCLOCK\f1
and a process lock, a text lock, or a data lock already exists on the calling
process.
.TP
\f4EINVAL\fP
.I op
is equal to
\f4TXTLOCK\f1
and a text lock, or a process lock already exists on the calling process.
.TP
\f4EINVAL\fP
.I op
is equal to
\f4DATLOCK\f1
and a data lock, or a process lock already exists on the calling
process.
.TP
\f4EINVAL\fP
.I op
is equal to
\f4UNLOCK\f1
and no lock exists on the calling process.
.TP
\f4EAGAIN\fP
Not enough memory.
.SH SEE ALSO
\f4exec\fP(2), \f4exit\fP(2), \f4fork\fP(2), \f4memcntl\fP(2).
.SH DIAGNOSTICS
Upon successful completion, a value of 0 is returned to the calling process.
Otherwise, a value of \-1 is returned and
\f4errno\fP
is set to indicate the error.
.SH NOTES
\f4memcntl\fP is the preferred interface to process locking.
