```{index} single: shmat (IPC::SysV) ``` ```{index} single: IPC::SysV::shmat ``` # shmat `shmat($id, $addr, $flag)` - attach the shared-memory segment `$id` and return an opaque address for it. Pass `undef` as `$addr` to let the kernel choose where to attach; `$flag` takes `SHM_RDONLY`, `SHM_RND` and friends. The value that comes back is a string of raw address bytes, meaningful only to `memread`, `memwrite` and `shmdt` - do not print it or do arithmetic on it. Returns `undef` with `$!` set on failure; a negative `$id` sets `$!` to `EINVAL` without reaching the kernel.