# man > IPC::SysV(3perl)

---
type: CommandReference
command: IPC::SysV
mode: perldoc
section: 3perl
source: perldoc
---

## Quick Reference

- `use IPC::SysV qw(IPC_STAT IPC_PRIVATE ...)` — import SysV IPC constants
- `ftok(PATH, ID)` — generate IPC key from path and ID (ID defaults to 1)
- `shmat(ID, ADDR, FLAG)` — attach shared memory segment (ADDR should be `undef`)
- `shmdt(ADDR)` — detach shared memory segment
- `memread(ADDR, VAR, POS, SIZE)` — read SIZE bytes from shared memory at ADDR, starting at POS
- `memwrite(ADDR, STRING, POS, SIZE)` — write SIZE bytes from STRING to shared memory at ADDR, starting at POS
- `IPC_CREAT`, `IPC_EXCL`, `IPC_NOWAIT`, `IPC_PRIVATE`, `IPC_RMID`, `IPC_SET`, `IPC_STAT` — common IPC operation constants
- `GETVAL`, `SETVAL`, `GETPID`, `GETNCNT`, `GETZCNT`, `GETALL`, `SETALL` — semaphore operation constants

## Name

[IPC::SysV](http://localhost/phpMan.php/perldoc/IPC%3A%3ASysV/markdown) - System V IPC constants and system calls

## Synopsis

perl
use IPC::SysV qw(IPC_STAT IPC_PRIVATE);
## Functions

- `ftok(PATH, ID)` — Return a key based on PATH and ID, which can be used as a key for `msgget`, `semget`, and `shmget`. See [ftok(3)](http://localhost/phpMan.php/man/ftok/3/markdown). If ID is omitted, it defaults to 1. If a single character is given for ID, the numeric value of that character is used.
- `shmat(ID, ADDR, FLAG)` — Attach the shared memory segment identified by ID to the address space of the calling process. See [shmat(2)](http://localhost/phpMan.php/man/shmat/2/markdown). ADDR should be `undef` unless you really know what you're doing.
- `shmdt(ADDR)` — Detach the shared memory segment located at the address specified by ADDR from the address space of the calling process. See [shmdt(2)](http://localhost/phpMan.php/man/shmdt/2/markdown).
- `memread(ADDR, VAR, POS, SIZE)` — Reads SIZE bytes from a memory segment at ADDR starting at position POS. VAR must be a variable that will hold the data read. Returns true if successful, or false if there is an error. `memread()` taints the variable.
- `memwrite(ADDR, STRING, POS, SIZE)` — Writes SIZE bytes from STRING to a memory segment at ADDR starting at position POS. If STRING is too long, only SIZE bytes are used; if STRING is too short, nulls are written to fill out SIZE bytes. Returns true if successful, or false if there is an error.

## Constants

The module defines and conditionally exports all constants from system include files needed by SysV IPC calls. Common ones include:

- **IPC constants**: `IPC_CREAT`, `IPC_EXCL`, `IPC_NOWAIT`, `IPC_PRIVATE`, `IPC_RMID`, `IPC_SET`, `IPC_STAT`
- **Semaphore constants**: `GETVAL`, `SETVAL`, `GETPID`, `GETNCNT`, `GETZCNT`, `GETALL`, `SETALL`, `SEM_A`, `SEM_R`, `SEM_UNDO`
- **Shared memory constants**: `SHM_RDONLY`, `SHM_RND`, `SHMLBA`
- **Permission constants**: `S_IRUSR`, `S_IWUSR`, `S_IRWXU`, `S_IRGRP`, `S_IWGRP`, `S_IRWXG`, `S_IROTH`, `S_IWOTH`, `S_IRWXO`

## See Also

[IPC::Msg](http://localhost/phpMan.php/perldoc/IPC%3A%3AMsg/markdown), [IPC::Semaphore](http://localhost/phpMan.php/perldoc/IPC%3A%3ASemaphore/markdown), [IPC::SharedMem](http://localhost/phpMan.php/perldoc/IPC%3A%3ASharedMem/markdown), [ftok(3)](http://localhost/phpMan.php/man/ftok/3/markdown), [shmat(2)](http://localhost/phpMan.php/man/shmat/2/markdown), [shmdt(2)](http://localhost/phpMan.php/man/shmdt/2/markdown)