Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
shmop(2)		      System Calls Manual		      shmop(2)

NAME
       shmat(),	shmdt()	- shared memory	operations

SYNOPSIS
DESCRIPTION
       attaches	 the  shared  memory segment associated	with the shared	memory
       identifier specified by shmid  to  the  data  segment  of  the  calling
       process.

       The segment is attached for reading if (shmflg is "true"; otherwise, it
       is attached for reading and writing.  It	is not possible	 to  attach  a
       segment for write only.

       If  the shared memory segment has never been attached to	by any process
       prior to	the current call, shmaddr must be specified as	zero  and  the
       segment	is  attached  at  a location selected by the operating system.
       That location is	identical in all processes accessing that shared  mem-
       ory  object.  Once the operating	system selects a location for a	shared
       memory segment, the same	location will be used  across  any  subsequent
       and calls on the	segment	until it is removed by the operation of

       If  this	 is not	the first call on the shared memory segment throughout
       the system, shmaddr must	either be zero or contain  a  nonzero  address
       that is identical to the	one returned from previous calls for that seg-
       ment.  Even if no processes are currently attached to the  segment,  as
       long as the segment has been attached before, the same rule applies.

       If  the	calling	 process is already attached to	the shared memory seg-
       ment, fails and returns regardless of what value	is passed in shmaddr.

       detaches	from the calling process's data	segment	the shared memory seg-
       ment located at the address specified by	shmaddr.

RETURN VALUE
       returns the following values:

	      Successful completion.
		     n	is  the	 data  segment	start  address of the attached
		     shared memory segment.
	      Failure.
		     The shared	memory segment is not attached.	 is set	to in-
		     dicate  the  error.   The symbol is defined in the	header
		     <sys/shm.h>.  No successful return	from will  return  the
		     value

       returns the following values:

	      Successful completion.
	      Failure.
		     is	set to indicate	the error.

ERRORS
       If fails, is set	to one of the following	values.

	      [EACCES]	     Operation	permission  is	denied	to the calling
			     process.

	      [EINVAL]	     shmid is not a valid  shared  memory  identifier,
			     (possibly	because	 the shared memory segment was
			     already removed using shmctl(2) with or the call-
			     ing process is already attached to	shmid.

	      [EINVAL]	     shmaddr is	not zero and the machine does not per-
			     mit nonzero values, or shmaddr is	not  equal  to
			     the current attach	location for the shared	memory
			     segment.

	      [ENOMEM]	     The available data	space is not large  enough  to
			     accommodate the shared memory segment.

	      [EMFILE]	     The  number of shared memory segments attached to
			     the calling  process  exceed  the	system-imposed
			     limit.

       If fails, is set	to one of the following	values.

	      [EINVAL]	     shmaddr  is not the data segment start address of
			     a shared memory segment.

EXAMPLES
       The following call  to  attaches	 the  shared  memory  segment  to  the
       process.	 This example assumes the process has a	valid shmid, which can
       be obtained by calling shmget(2).

       The following call to then detaches the shared memory segment.

SEE ALSO
       ipcs(1),	exec(2), exit(2), fork(2), ftok(3C), shmctl(2),	shmget(2).

STANDARDS CONFORMANCE
								      shmop(2)

NAME | SYNOPSIS | DESCRIPTION | RETURN VALUE | ERRORS | EXAMPLES | SEE ALSO | STANDARDS CONFORMANCE

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=shmop&sektion=2&manpath=HP-UX+11.22>

home | help