MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Standard C Library Functions                         shmopen(3C)



NAME
     shmopen - open a shared memory object

SYNOPSIS
     #include 

     int shmopen(const char *name, int oflag, modet mode);


DESCRIPTION
     The shmopen() function establishes a connection  between  a
     shared  memory  object  and a file descriptor. It creates an
     open file description  that  refers  to  the  shared  memory
     object  and  a file descriptor that refers to that open file
     description. The file descriptor is used by other  functions
     to  refer  to  that  shared memory object. The name argument
     points to a string naming a  shared  memory  object.  It  is
     unspecified  whether the name appears in the file system and
     is visible to other functions that take pathnames  as  argu-
     ments.  The name argument conforms to the construction rules
     for a pathname. The first character of  name must be a slash
     (/)  character  and the remaining characters of  name cannot
     include any  slash  characters.   For  maximum  portability,
     name  should  include  no  more than 14 characters, but this
     limit is not enforced.


     If successful, shmopen() returns a file descriptor for  the
     shared  memory  object  that  is  the  lowest  numbered file
     descriptor not currently open for  that  process.  The  open
     file  description  is new, and therefore the file descriptor
     does not share it with any other processes. It  is  unspeci-
     fied  whether  the  file  offset is set. The FDCLOEXEC file
     descriptor flag associated with the new file  descriptor  is
     set.


     The file status flags and file access modes of the open file
     description  are  according to the value of oflag. The oflag
     argument is the bitwise inclusive OR of the following  flags
     defined   in  the  header  .  Applications  specify
     exactly one of the first two values (access modes) below  in
     the value of oflag:

     ORDONLY     Open for read access only.


     ORDWR       Open for read or write access.







SunOS 5.11           Last change: 5 Feb 2008                    1






Standard C Library Functions                         shmopen(3C)



     Any combination of the remaining flags may be  specified  in
     the value of oflag:

     OCREAT     If the shared memory object  exists,  this  flag
                 has  no  effect,  except  as  noted under OEXCL
                 below. Otherwise the  shared  memory  object  is
                 created; the user ID of the shared memory object
                 will be set to the effective user ID of the pro-
                 cess;  the  group ID of the shared memory object
                 will be set to a system default group ID  or  to
                 the  effective group ID of the process. The per-
                 mission bits of the shared memory object will be
                 set  to  the  value  of the mode argument except
                 those set in the file mode creation mask of  the
                 process.  When  bits in mode other than the file
                 permission bits are set, the effect is  unspeci-
                 fied.  The mode argument does not affect whether
                 the shared memory object is opened for  reading,
                 for  writing,  or  for  both.  The shared memory
                 object has a size of zero.


     OEXCL      If OEXCL and OCREAT are set, shmopen()  fails
                 if  the  shared  memory object exists. The check
                 for the existence of the  shared  memory  object
                 and  the  creation  of the object if it does not
                 exist is atomic with respect to other  processes
                 executing  shmopen()  naming  the  same  shared
                 memory object with OEXCL and  OCREAT  set.  If
                 OEXCL is set and OCREAT is not set, the result
                 is undefined.


     OTRUNC     If the shared memory object exists,  and  it  is
                 successfully  opened  ORDWR, the object will be
                 truncated to zero length and the mode and  owner
                 will  be  unchanged  by  this function call. The
                 result of using OTRUNC with ORDONLY  is  unde-
                 fined.



     When a shared memory object is created,  the  state  of  the
     shared memory object, including all data associated with the
     shared memory  object,  persists  until  the  shared  memory
     object  is unlinked and all other references are gone. It is
     unspecified whether the name and shared memory object  state
     remain valid after a system reboot.

RETURN VALUES
     Upon successful completion, the shmopen() function  returns
     a  non-negative  integer  representing  the  lowest numbered



SunOS 5.11           Last change: 5 Feb 2008                    2






Standard C Library Functions                         shmopen(3C)



     unused file descriptor. Otherwise, it returns  -1  and  sets
     errno to indicate the error condition.

ERORS
     The shmopen() function will fail if:

     EACES           The shared memory  object  exists  and  the
                      permissions  specified by oflag are denied,
                      or the shared memory object does not  exist
                      and  permission to create the shared memory
                      object is denied, or OTRUNC  is  specified
                      and write permission is denied.


     EXIST           OCREAT and OEXCL are set  and  the  named
                      shared memory object already exists.


     EINTR            The shmopen() operation was interrupted by
                      a signal.


     EINVAL           The shmopen() operation is  not  supported
                      for the given name.


     EMFILE           Too many file descriptors are currently  in
                      use by this process.


     ENAMETOLONG     The  length  of  the  name  string  exceeds
                      PATHMAX, or a pathname component is longer
                      than NAMEMAX while POSIXNOTRUNC  is  in
                      effect.


     ENFILE           Too  many   shared   memory   objects   are
                      currently open in the system.


     ENOENT           OCREAT is not set  and  the  named  shared
                      memory object does not exist.


     ENOSPC           There is insufficient space for  the  crea-
                      tion of the new shared memory object.


     ENOSYS           The shmopen() function is not supported by
                      the system.





SunOS 5.11           Last change: 5 Feb 2008                    3






Standard C Library Functions                         shmopen(3C)



ATRIBUTES
     See attributes(5) for descriptions of the  following  attri-
     butes:



     
     ATRIBUTE TYPE               ATRIBUTE VALUE             
    
     Interface Stability          Committed                   
    
     MT-Level                     MT-Safe                     
    
     Standard                     See standards(5).           
    


SEE ALSO
     close(2),  dup(2),  exec(2),  fcntl(2),  mmap(2),  umask(2),
     shmunlink(3C),  sysconf(3C), fcntl.h(3HEAD), attributes(5),
     standards(5)

NOTES
     Solaris 2.6 was the first release to support  the  Asynchro-
     nous  Input  and  Output option. Prior to this release, this
     function always returned -1 and set errno to ENOSYS.





























SunOS 5.11           Last change: 5 Feb 2008                    4



OpenSolaris man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™