.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved .TH "SHMCTL" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" .\" shmctl .SH NAME shmctl \- XSI shared memory control operations .SH SYNOPSIS .LP \fB#include .br .sp int shmctl(int\fP \fIshmid\fP\fB, int\fP \fIcmd\fP\fB, struct shmid_ds *\fP\fIbuf\fP\fB); \fP \fB .br \fP .SH DESCRIPTION .LP The \fIshmctl\fP() function operates on XSI shared memory (see the Base Definitions volume of IEEE\ Std\ 1003.1-2001, Section 3.340, Shared Memory Object). It is unspecified whether this function interoperates with the realtime interprocess communication facilities defined in \fIRealtime\fP . .LP The \fIshmctl\fP() function provides a variety of shared memory control operations as specified by \fIcmd\fP. The following values for \fIcmd\fP are available: .TP 7 IPC_STAT Place the current value of each member of the \fBshmid_ds\fP data structure associated with \fIshmid\fP into the structure pointed to by \fIbuf\fP. The contents of the structure are defined in \fI\fP. .TP 7 IPC_SET Set the value of the following members of the \fBshmid_ds\fP data structure associated with \fIshmid\fP to the corresponding value found in the structure pointed to by \fIbuf\fP: .sp .RS .nf \fBshm_perm.uid shm_perm.gid shm_perm.mode \fP Low-order nine bits. .fi .RE .LP IPC_SET can only be executed by a process that has an effective user ID equal to either that of a process with appropriate privileges or to the value of \fIshm_perm.cuid\fP or \fIshm_perm.uid\fP in the \fBshmid_ds\fP data structure associated with \fIshmid\fP. .TP 7 IPC_RMID Remove the shared memory identifier specified by \fIshmid\fP from the system and destroy the shared memory segment and \fBshmid_ds\fP data structure associated with it. IPC_RMID can only be executed by a process that has an effective user ID equal to either that of a process with appropriate privileges or to the value of \fIshm_perm.cuid\fP or \fIshm_perm.uid\fP in the \fBshmid_ds\fP data structure associated with \fIshmid\fP. .sp .SH RETURN VALUE .LP Upon successful completion, \fIshmctl\fP() shall return 0; otherwise, it shall return -1 and set \fIerrno\fP to indicate the error. .SH ERRORS .LP The \fIshmctl\fP() function shall fail if: .TP 7 .B EACCES The argument \fIcmd\fP is equal to IPC_STAT and the calling process does not have read permission; see \fIXSI Interprocess Communication\fP \&. .TP 7 .B EINVAL The value of \fIshmid\fP is not a valid shared memory identifier, or the value of \fIcmd\fP is not a valid command. .TP 7 .B EPERM The argument \fIcmd\fP is equal to IPC_RMID or IPC_SET and the effective user ID of the calling process is not equal to that of a process with appropriate privileges and it is not equal to the value of \fIshm_perm.cuid\fP or \fIshm_perm.uid\fP in the data structure associated with \fIshmid\fP. .sp .LP The \fIshmctl\fP() function may fail if: .TP 7 .B EOVERFLOW The \fIcmd\fP argument is IPC_STAT and the \fIgid\fP or \fIuid\fP value is too large to be stored in the structure pointed to by the \fIbuf\fP argument. .sp .LP \fIThe following sections are informative.\fP .SH EXAMPLES .LP None. .SH APPLICATION USAGE .LP The POSIX Realtime Extension defines alternative interfaces for interprocess communication. Application developers who need to use IPC should design their applications so that modules using the IPC routines described in \fIXSI Interprocess Communication\fP can be easily modified to use the alternative interfaces. .SH RATIONALE .LP None. .SH FUTURE DIRECTIONS .LP None. .SH SEE ALSO .LP \fIXSI Interprocess Communication\fP , \fIRealtime\fP , \fIshmat\fP() , \fIshmdt\fP() , \fIshmget\fP() , \fIshm_open\fP() , \fIshm_unlink\fP() , the Base Definitions volume of IEEE\ Std\ 1003.1-2001, \fI\fP .SH COPYRIGHT Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .