PRCTL(2) PRCTL(2)
NAME
prctl - operations on a process
C SYNOPSIS
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/prctl.h>
ptrdifft prctl (unsigned option, ...);
DESCRIPTION
prctl provides information about processes and the ability to control
certain of their attributes. The return type ptrdiff_t is used so that
prctl can return an integral value that is large enough to return a
pointer/address. option specifies one of the following actions:
PRMAXPROCS returns the system imposed limit on the number of
processes per user.
PRMAXPPROCS returns the maximum number of processors the calling
process can utilize. If the caller is restricted (see
sysmp(2)) to run on a particular processor then
PRMAXPPROCS will return 1. If some of the processors
in the complex have been restricted (see mpadmin(1))
these will not be counted.
PRISBLOCKED returns 1 if the specified process is currently blocked.
The second argument, interpreted as type pidt,
specifies the target process's pid. Passing in 0
implies the caller. Since other processes could have
subsequently unblocked the subject process, the result
should be considered as a snapshot only.
PRSETSTACKSIZE sets the maximum stack size for the current process.
This affects future stack growths and forks only. The
new value, suitably rounded, is returned. The second
argument, interpreted as an rlimt, defines the desired
stack size in bytes. This option and the RLIMITSTACK
option of setrlimit(2) act on the same value.
PRGETSTACKSIZE returns the current process's maximum stack size in
bytes. This size is an upper limit on the size of the
current process's stack.
PRUNBLKONEXEC sets a flag so that when the calling process
subsequently calls exec(2), the process whose pid is
specified by the second argument is unblocked. This can
be used in conjunction with the PRBLOCK option of
sproc(2) to provide race-free process creation.
Page 1
PRCTL(2) PRCTL(2)
PRATOMICSIM set a flag so that the kernel provides assistance for
performing atomic operations on hardware that requires
it. It is for use by libc and shouldn't be called by a
user application.
PRSETEXITSIG controls whether all members of a share group will be
signaled if any one of them leaves the share group
(whether via exit(2) or exec(2) or as the result of an
abnormal termination, such as caused by a segmentation
violation or an uncatchable signal). If the second
argument, interpreted as an int is 0, then normal IRIX
process termination rules apply, namely that the parent
might be sent a SIGCLD upon death of child, but no
indication of death of parent is given. If the second
argument is a valid signal number [see signal(2)] then
if any member of a share group leaves the share group, a
signal is sent to ALL surviving members of the share
group.
PRSETABORTSIG controls whether all members of a share group will be
signaled if any one of them exits the share group
unnaturally. This option works like PRSETEXITSIG ,
except that the signal is not generated if the share
group member exits normally, that is, by way of exit(2)
or exec(2). Further, the PRSETABORTSIG and
PRSETEXITSIG actions cannot be in effect
simultaneously; a call which specifies either of these
nullifies any previous calls for these actions.
PRRESIDENT makes the process immune to process swapout. Its pages
are still subject to paging - these can be locked by
using mpin(2).
PRTERMCHILD causes the calling process to be automatically sent a
SIGHUP when its parent process dies. This effect is NOT
inherited: it applies only to the process that requested
it. The caller must have set its handler for SIGHUP to
either be caught or SIGDFL. Note that processes
started in the background have their SIGHUP handler set
to SIGIGN by the shell. Child processes getting a
SIGHUP signal should probably check the value of
getppid(2) to be sure their parent really died (and thus
their parent pid will be set to 1).
PRATTACHADDR attaches the virtual segment containing the address
given by the third argument in the process whose pid is
given by the second argument to the calling process.
The second argument (pid) is interpreted as a pidt.
The third argument (address) is interpreted as a
caddrt. Both processes must be members of the same
share group. The address of where the virtual segment
was attached is returned. This address has the same
Page 2
PRCTL(2) PRCTL(2)
logical offset into the virtual space as the passed in
address. A process may always attach a portion of its
address space back onto itself without being a share
group process.
PRATTACHADDRPERM
performs the same function as PR_ATTACHADDR but allows
the caller to specify the desired protection attributes
of the attach which must be a subset of the attributes
on the region being attached. Also returns to the
caller additional information about the region attached,
like base address and size of region. In order to allow
the additional attributes, the second argument is a
pointer to the input parameter block which is of type
prattach_args_t and the third argument is a pointer to
the return values and is of type prattach_results_t.
Intended for use by MPI libraries.
PRDETACHADDR is not implemented yet.
PRGETSHMASK returns the mask stating which resources are being
shared with the share group member whose pid is
specified by the second argument. It can also be used
to gather information about the existence of other
processes. If the second argument is 0 or equal to the
callers pid, then the callers share mask is returned.
If the caller is not a member of a share group then an
error is returned. If the process specified by the
second argument does not exist, is not a member of the
callers share group, or the caller does not have
permission to query the process, an error is returned.
If the caller and target process are in the same share
group the bit-wise 'and' of the callers share mask and
the target process's share mask is returned.
PRGETNSHARE returns the number of processes in the share group. If
the calling process has never been part of a share group
0 is returned.
PRCOREPID Changes the name of the file used to hold the core image
of the process from core to core.pid. The second
argument is interpreted as a pidt and specifies which
process to act on. A value of 0 signifies the calling
process. If the third argument, interpreted as an int,
is zero then the core file name is changed back to the
standard name - core. This state is inherited on
fork(2) and sproc(2) and is reset on exec(2). Note that
this mechanism may be defeated by some system wide
configuration settings.
Page 3
PRCTL(2) PRCTL(2)
prctl will fail if one or more of the following are true:
[EINVAL] option is not valid.
[ESRCH] The second argument passed with the PRISBLOCKED,
PRUNBLKONEXEC, PRCOREPID, or PRGETSHMASK option doesn't
match the pid of any process.
[EINVAL] The value given for the new maximum stack size is negative or
exceeds the maximum process size allowed.
[EINVAL] The value given for the PRSETEXITSIG option is not a valid
signal number.
[EINVAL] The calling process already has specified a process (or the
specified process is the caller itself) to be unblocked on
exec via the PRUNBLKONEXEC option.
[EPERM] The caller does not have permission to unblock or query the
process specified by the second argument for the
PRUNBLKONEXEC, PRISBLOCKED, PRCOREPID, or PRGETSHMASK
options.
[EINVAL] The PRGETSHMASK option was specified and the second argument
does not correspond to a pid of a process that is in the
caller's share group.
[EINVAL] The PRGETSHMASK option was specified and the caller is not a
share group member.
SEE ALSO
blockproc(2), signal(2), setrlimit(2), sproc(2), usinit(3P).
DIAGNOSTICS
Upon successful completion, prctl returns the requested information.
Otherwise, a value of -1 is returned to the calling process, and errno is
set to indicate the error.
Page 4