{
    "mode": "info",
    "parameter": "IPC::SharedMem",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/IPC%3A%3ASharedMem/json",
    "generated": "2026-07-05T11:58:21Z",
    "synopsis": "use IPC::SysV qw(IPCPRIVATE SIRUSR SIWUSR);\nuse IPC::SharedMem;\n$shm = IPC::SharedMem->new(IPCPRIVATE, 8, SIRWXU);\n$shm->write(pack(\"S\", 4711), 2, 2);\n$data = $shm->read(0, 2);\n$ds = $shm->stat;\n$shm->remove;",
    "sections": {
        "NAME": {
            "content": "IPC::SharedMem - SysV Shared Memory IPC object class\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use IPC::SysV qw(IPCPRIVATE SIRUSR SIWUSR);\nuse IPC::SharedMem;\n\n$shm = IPC::SharedMem->new(IPCPRIVATE, 8, SIRWXU);\n\n$shm->write(pack(\"S\", 4711), 2, 2);\n\n$data = $shm->read(0, 2);\n\n$ds = $shm->stat;\n\n$shm->remove;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "A class providing an object based interface to SysV IPC shared memory.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "new ( KEY , SIZE , FLAGS )\nCreates a new shared memory segment of \"SIZE\" bytes size associated\nwith \"KEY\". A new segment is created if\n\no   \"KEY\" is equal to \"IPCPRIVATE\"\n\no   \"KEY\" does not already have a shared memory segment associated\nwith it, and \"FLAGS & IPCCREAT\" is true.\n\nOn creation of a new shared memory segment \"FLAGS\" is used to set\nthe permissions.  Be careful not to set any flags that the Sys V\nIPC implementation does not allow: in some systems setting execute\nbits makes the operations fail.\n\nid  Returns the shared memory identifier.\n\nread ( POS, SIZE )\nRead \"SIZE\" bytes from the shared memory segment at \"POS\". Returns\nthe string read, or \"undef\" if there was an error. The return value\nbecomes tainted. See shmread.\n\nwrite ( STRING, POS, SIZE )\nWrite \"SIZE\" bytes to the shared memory segment at \"POS\". Returns\ntrue if successful, or false if there is an error. See shmwrite.\n\nremove\nRemove the shared memory segment from the system or mark it as\nremoved as long as any processes are still attached to it.\n\nisremoved\nReturns true if the shared memory segment has been removed or\nmarked for removal.\n\nstat\nReturns an object of type \"IPC::SharedMem::stat\" which is a sub-\nclass of \"Class::Struct\". It provides the following fields. For a\ndescription of these fields see you system documentation.\n\nuid\ngid\ncuid\ncgid\nmode\nsegsz\nlpid\ncpid\nnattch\natime\ndtime\nctime\n\nattach ( [FLAG] )\nPermanently attach to the shared memory segment. When a\n\"IPC::SharedMem\" object is attached, it will use memread and\nmemwrite instead of shmread and shmwrite for accessing the shared\nmemory segment.  Returns true if successful, or false on error. See\nshmat(2).\n\ndetach\nDetach from the shared memory segment that previously has been\nattached to. Returns true if successful, or false on error. See\nshmdt(2).\n\naddr\nReturns the address of the shared memory that has been attached to\nin a format suitable for use with \"pack('P')\". Returns \"undef\" if\nthe shared memory has not been attached.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "IPC::SysV, Class::Struct\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Marcus Holland-Moritz <mhx@cpan.org>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Version 2.x, Copyright (C) 2007-2013, Marcus Holland-Moritz.\n\nVersion 1.x, Copyright (c) 1997, Graham Barr.\n\nThis program is free software; you can redistribute it and/or modify it\nunder the same terms as Perl itself.\n\nperl v5.34.0                      2026-06-23             IPC::SharedMem(3perl)",
            "subsections": []
        }
    },
    "summary": "IPC::SharedMem - SysV Shared Memory IPC object class",
    "flags": [],
    "examples": [],
    "see_also": []
}