IceWalkers.com - Linux Software downloads and news
Name : Password :
Linux SoftwareLinux RPMLinux HowtosLink UsAboutAdvertise

shmctl (2)

SHMCTL(2)                  Linux Programmer's Manual                 SHMCTL(2)



NAME
       shmctl - shared memory control

SYNOPSIS
       #include<sys/ipc.h>

       #include<sys/shm.h>

       intshmctl(int shmid,int cmd,structshmid_ds*buf);

DESCRIPTION
       shmctl() allows the user to receive information on a shared memory seg-
       ment, set the owner, group, and permissions of a shared memory segment,
       or  destroy  a segment. The information about the segment identified by
       shmid is returned in a shmid_ds structure:

           struct shmid_ds {
               struct ipc_perm shm_perm;  /* operation perms */
               int shm_segsz;             /* size of segment (bytes) */
               time_t shm_atime;          /* last attach time */
               time_t shm_dtime;          /* last detach time */
               time_t shm_ctime;          /* last change time */
               unsigned short shm_cpid;   /* pid of creator */
               unsigned short shm_lpid;   /* pid of last operator */
               short shm_nattch;          /* no. of current attaches */
               ...
           };

       The highlighted fields in the member shm_perm can be set:

           struct ipc_perm {
               key_t  key;
               ushortuid;   /* owner euid and egid */
               ushortgid;
               ushort cuid;  /* creator euid and egid */
               ushort cgid;
               ushortmode;  /* lower 9 bits of access modes */
               ushort seq;   /* sequence number */
           };

       The following cmds are available:

       IPC_STAT    is used to copy the information  about  the  shared  memory
                   segment into the buffer buf. The user must have read access
                   to the shared memory segment.

       IPC_SET     is used to apply the changes the user has made to the  uid,
                   gid, or mode members of the shm_perms field.  Only the low-
                   est 9 bits of mode are used.  The shm_ctime member is  also
                   updated.   The  user  must  be  the  owner, creator, or the
                   super-user.

       IPC_RMID    is used to mark the segment as destroyed. It will  actually
                   be  destroyed  after  the  last  detach.   (I.e.,  when the
                   shm_nattch member of the associated structure  shmid_ds  is
                   zero.)   The user must be the owner, creator, or the super-
                   user.

       The user must ensure that a segment is eventually destroyed;  otherwise
       its pages that were faulted in will remain in memory or swap.

       In  addition,  the super-user can prevent or allow swapping of a shared
       memory segment with the following cmds: (Linux only)

       SHM_LOCK    prevents swapping of a shared memory segment. The user must
                   fault  in  any  pages that are required to be present after
                   locking is enabled.

       SHM_UNLOCK  allows the shared memory segment to be swapped out.

       The IPC_INFO, SHM_STAT and SHM_INFO  control  calls  are  used  by  the
       ipcs(8)  program to provide information on allocated resources.  In the
       future, these may be modified as needed or moved to a proc file  system
       interface.

RETURNVALUE
       0 is returned on success, -1 on error.

ERRORS
       On error, errno will be set to one of the following:

       EACCES      is  returned  if  IPC_STAT  is requested and shm_perm.modes
                   does not allow read access for shmid.

       EFAULT      The argument cmd has value  IPC_SET  or  IPC_STAT  but  the
                   address pointed to by buf isn't accessible.

       EINVAL      is  returned  if shmid is not a valid identifier, or cmd is
                   not a valid command.

       EIDRM       is returned if shmid points to a removed identifier.

       EPERM       is returned if IPC_SET or IPC_RMID is  attempted,  and  the
                   effective user ID of the calling process is not the creator
                   (as  found  in  shm_perm.cuid),  the  owner  (as  found  in
                   shm_perm.uid), or the super-user.

       EOVERFLOW   is  returned  if  IPC_STAT is attempted, and the gid or uid
                   value is too large to be stored in the structure pointed to
                   by buf.

NOTE
       Various  fields  in  a  struct shmid_ds were shorts under Linux 2.2 and
       have become longs under Linux 2.4. To take advantage of this, a  recom-
       pilation  under glibc-2.1.91 or later should suffice.  (The kernel dis-
       tinguishes old and new calls by a IPC_64 flag in cmd.)

CONFORMINGTO
       SVr4, SVID.  SVr4 documents additional error conditions EINVAL, ENOENT,
       ENOSPC, ENOMEM, EEXIST.  Neither SVr4 nor SVID documents an EIDRM error
       condition.

SEEALSO
       shmget(2), shmop(2)



Linux 2.4.1                       2002-01-05                         SHMCTL(2)

_Exitgetsockoptoutwshmat
_exitgettidoutw_pshmctl
_llseekgettimeofdaypauseshmdt
_newselectgetuidpersonalityshmget
_sysctlgttypipeshmop
acceptidlepivot_rootshutdown
accessinbpollsigaction
acctinb_pprctlsigaltstack
adjtimexinlpreadsigblock
afs_syscallinl_pprofsiggetmask
alarminsbpselectsigmask
alloc_hugepagesinslptracesignal
arch_prctlinswpwritesigpause
bdflushintroquotactlsigpending
bindinwreadsigprocmask
breakinw_preaddirsigqueue
brkioctlreadlinksigreturn
cacheflushioctl_listreadvsigsetmask
capgetiopermrebootsigsuspend
capsetioplrecvsigtimedwait
chdiripcrecvfromsigvec
chmodkillrecvmsgsigwaitinfo
chownkillpgrenamesocket
chrootlchownrmdirsocketcall
clonelinksbrksocketpair
closelistensched_get_priority_maxssetmask
connectllseeksched_get_priority_minstat
creatlocksched_getaffinitystatfs
duplseeksched_getparamstime
dup2lstatsched_getschedulerstty
execvemadvisesched_rr_get_intervalswapoff
exitmincoresched_setaffinityswapon
fchdirmkdirsched_setparamsymlink
fchmodmknodsched_setschedulersync
fchownmlocksched_yieldsyscall
fcntlmlockallselectsyscalls
fdatasyncmmapselect_tutsysctl
flockmmap2semctlsysfs
forkmodify_ldtsemgetsysinfo
free_hugepagesmountsemopsyslog
fstatmprotectsendtime
fstatfsmpxsendfiletimes
fsyncmremapsendmsgtkill
ftruncatemsgctlsendtotruncate
futexmsggetsetcontextumask
getcontextmsgopsetdomainnameumount
getdentsmsgrcvsetegidumount2
getdomainnamemsgsndseteuiduname
getdtablesizemsyncsetfsgidundocumented
getegidmunlocksetfsuidunimplemented
geteuidmunlockallsetgidunlink
getgidmunmapsetgroupsuselib
getgroupsnanosleepsethostidustat
gethostidnfsservctlsethostnameutime
gethostnamenicesetitimerutimes
getitimerobsoletesetpgidvfork
getpagesizeoldfstatsetpgrpvhangup
getpeernameoldlstatsetpriorityvm86
getpgidoldoldunamesetregidwait
getpgrpoldstatsetresgidwait3
getpidoldunamesetresuidwait4
getppidopensetreuidwaitpid
getpriorityoutbsetrlimitwrite
getresgidoutb_psetsidwritev
getresuidoutlsetsockopt 
getrlimitoutl_psettimeofday 
getrusageoutsbsetuid 
getsidoutslsetup 


The Gimp 2.6.3
GNU Image Manipulation Program
Linux Kernel 2.6 2.6.27.7
Linux Kernel
Battle for Wesnoth 1.4.6
Fantasy Turn-Based Strategy Game
DeleGate 9.9.0-pre8
Proxy server which runs on multiple platforms
Safesquid proxy server 4.2.2.RC8.14B
Antivirus and content filtering proxy server
Thunderbird 2.0.0.18
An email and newsgroup client with powerful, new junk mail controls
Wine 1.1.9
Free implementation of Windows on Unix
WebGUI 7.5.34
A fully featured content management system.
KOffice 2.0 beta3
Integrated office suite for KDE
LimeWire 4.18.8
Gnutella Client
Free IT Magazines, White Papers, eBooks, and more !
Oracle Magazine

Contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more.

eWeek

The essential technology information source for builders of e-business.

BusinessWeek (Digital Edition)

Provides readers a deeper understanding of the trends that drive growth, and what best practices keep them ahead of the competition.

Linux Software Map
Find Linux RPM
Best Rated Linux Software
Most Rated Linux Software
Linux Distributions
Linux Howtos
Quick Survey

Please take our survey and help us improve our website to serve you better.

Thank you.
Linux Software
Linux / IT Resources
Site Resources
Google
Privacy Policy
Contact Us
Submit Software
Advertising info