1 .\"   $OpenBSD: shmctl.2,v 1.2 1996/10/08 01:20:15 michaels Exp $
 
   2 .\"     $NetBSD: shmctl.2,v 1.1 1995/10/16 23:49:30 jtc Exp $   
 
   4 .\" Copyright (c) 1995 Frank van der Linden
 
   5 .\" All rights reserved.
 
   7 .\" Redistribution and use in source and binary forms, with or without
 
   8 .\" modification, are permitted provided that the following conditions
 
  10 .\" 1. Redistributions of source code must retain the above copyright
 
  11 .\"    notice, this list of conditions and the following disclaimer.
 
  12 .\" 2. Redistributions in binary form must reproduce the above copyright
 
  13 .\"    notice, this list of conditions and the following disclaimer in the
 
  14 .\"    documentation and/or other materials provided with the distribution.
 
  15 .\" 3. All advertising materials mentioning features or use of this software
 
  16 .\"    must display the following acknowledgement:
 
  17 .\"      This product includes software developed for the NetBSD Project
 
  18 .\"      by Frank van der Linden
 
  19 .\" 4. The name of the author may not be used to endorse or promote products
 
  20 .\"    derived from this software without specific prior written permission
 
  22 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 
  23 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 
  24 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 
  25 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 
  26 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 
  27 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
  28 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
  29 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
  30 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 
  31 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
  38 .Nd shared memory control operations
 
  40 .Fd #include <sys/shm.h>
 
  45 .Fa "struct shmid_ds *buf"
 
  50 system call performs some control operations on the shared memory area
 
  53 Each shared memory segment has a data structure associated with it,
 
  54 parts of which may be altered by
 
  56 and parts of which determine the actions of
 
  58 This structure is defined as follows in
 
  62     struct ipc_perm  shm_perm;     /* operation permissions */
 
  63     int              shm_segsz;    /* size of segment in bytes */
 
  64     pid_t            shm_lpid;     /* pid of last shm op */
 
  65     pid_t            shm_cpid;     /* pid of creator */
 
  66     short            shm_nattch;   /* # of current attaches */
 
  67     time_t           shm_atime;    /* last shmat() time*/
 
  68     time_t           shm_dtime;    /* last shmdt() time */
 
  69     time_t           shm_ctime;    /* last change by shmctl() */
 
  70     void            *shm_internal; /* sysv stupidity */
 
  78 structure used inside the
 
  82 structure is defined in
 
  87   uid_t           uid;   /* Owner's user ID */
 
  88   gid_t           gid;   /* Owner's group ID */
 
  89   uid_t           cuid;  /* Creator's user ID */
 
  90   gid_t           cgid;  /* Creator's group ID */
 
  91   mode_t          mode;  /* r/w permission (see chmod(2)) */
 
  92   unsigned short  _seq;  /* Reserved for internal use */
 
  93   key_t           _key;  /* Reserved for internal use */
 
  97 The operation to be performed by
 
 102 .Bl -tag -width IPC_RMIDX
 
 104 Gather information about the shared memory segment and place it in the
 
 105 structure pointed to by
 
 113 fields in the structure associated with
 
 115 The values are taken from the corresponding fields in the structure
 
 118 This operation can only be executed by the super-user, or a process that
 
 119 has an effective user id equal to either 
 
 123 in the data structure associated with the shared memory segment.
 
 125 Remove the shared memory segment specified by
 
 127 and destroy the data associated with it. Only the super-user or a process
 
 128 with an effective uid equal to the 
 
 132 values in the data structure associated with the queue can do this.
 
 135 The read and write permissions on a shared memory identifier
 
 136 are determined by the
 
 138 field in the same way as is
 
 141 but the effective uid can match either the
 
 146 effective gid can match either
 
 151 Upon successful completion, a value of 0 is returned.
 
 152 Otherwise, -1 is returned and the global variable
 
 154 is set to indicate the error.
 
 161 The command is IPC_STAT
 
 162 and the caller has no read permission for this shared memory segment.
 
 166 specifies an invalid address.
 
 170 is not a valid shared memory segment identifier.
 
 172 is not a valid command.
 
 176 is equal to IPC_SET or IPC_RMID and the caller is not the super-user,\
 
 177 nor does the effective uid match either the
 
 181 fields of the data structure associated with the shared memory segment.
 
 182 An attempt is made to increase the value of
 
 185 but the caller is not the super-user.
 
 188 .Fd #include <sys/types.h>
 
 189 .Fd #include <sys/ipc.h>
 
 190 .Fd #include <sys/shm.h>
 
 192 All of these include files are necessary.
 
 193 .Sh LEGACY DESCRIPTION
 
 198 structure used inside the
 
 202 structure, as defined in
 
 207     __uint16_t cuid;  /* Creator's user id */
 
 208     __uint16_t cgid;  /* Creator's group id */
 
 209     __uint16_t uid;   /* Owner's user id */
 
 210     __uint16_t gid;   /* Owner's group id */
 
 211     mode_t     mode;  /* r/w permission (see chmod(2)) */
 
 212     __uint16_t seq;   /* Reserved for internal use */
 
 213     key_t      key;   /* Reserved for internal use */
 
 217 This structure is maintained for binary backward compatibility
 
 218 with previous versions of the interface.
 
 219 New code should not use this interface,
 
 220 because ID values may be truncated.
 
 223 LEGACY mode limits the allowable uid/gid ranges to 0-32767.
 
 224 If the user has a UID that is out of this range (e.g., "nobody"),
 
 225 software using the LEGACY API will not behave as expected.