shm

package module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2026 License: BSD-3-Clause Imports: 2 Imported by: 14

README

shm

Status Go Reference Go Report Card

shm implements System V shared memory functions (shmctl, shmget, shmat, shmdt) in pure Go (except solaris, see #24357).

Installation

go get -u github.com/gen2brain/shm

More

For System V Message Queue IPC (i.e. msgctl, msgget, msgrcv, msgsnd) see ipc.

Documentation

Overview

Package shm implements System V shared memory functions (shmctl, shmget, shmat, shmdt).

This platform does not provide System V shared memory; every function returns errUnsupported so that programs depending on the package still build.

Index

Constants

View Source
const (

	// Create key if key does not exist.
	IPC_CREAT = 01000
	// Fail if key exists.
	IPC_EXCL = 02000
	// Return error on wait.
	IPC_NOWAIT = 04000

	// Private key.
	IPC_PRIVATE = 0

	// Attach read-only access.
	SHM_RDONLY = 010000
	// Round attach address to SHMLBA.
	SHM_RND = 020000
	// Take-over region on attach.
	SHM_REMAP = 040000
	// Execution access.
	SHM_EXEC = 0100000

	// Lock segment (root only).
	SHM_LOCK = 1
	// Unlock segment (root only).
	SHM_UNLOCK = 12

	// Remove identifier.
	IPC_RMID = 0
	// Set `ipc_perm` options.
	IPC_SET = 1
	// Get `ipc_perm' options.
	IPC_STAT = 2
)

Constants.

Variables

This section is empty.

Functions

func At added in v0.2.2

func At(shmId int, shmAddr uintptr, shmFlg int) (data []byte, err error)

At attaches the shared memory segment identified by shmId.

func Ctl added in v0.2.2

func Ctl(shmId int, cmd int, buf *IdDs) (int, error)

Ctl performs the control operation specified by cmd on the shared memory segment whose identifier is given in shmId.

func Dt added in v0.2.2

func Dt(data []byte) error

Dt detaches the shared memory segment.

func Get added in v0.2.2

func Get(key int, size int, shmFlg int) (shmId int, err error)

Get allocates a shared memory segment.

func Rm added in v0.2.2

func Rm(shmId int) error

Rm removes the shared memory segment.

func Size added in v0.2.2

func Size(shmId int) (int64, error)

Size returns size of shared memory segment.

Types

type IdDs

type IdDs struct {
	// Operation permission struct.
	Perm Perm
	// Size of segment in bytes.
	SegSz uint64
}

IdDs describes shared memory segment.

type Perm

type Perm struct{}

Perm is used to pass permission information to IPC operations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL