diff --git a/src/Shm/SharedMemoryBlock.php b/src/Shm/SharedMemoryBlock.php index ec23762..63803b6 100644 --- a/src/Shm/SharedMemoryBlock.php +++ b/src/Shm/SharedMemoryBlock.php @@ -29,7 +29,7 @@ class SharedMemoryBlock */ public function __construct(KeyInterface $key, string $flags, int $memsize, int $perm = 0666) { - if (!($shm_resource = shmop_open($key->getKey(), $memsize, $perm))) { + if (!($shm_resource = shmop_open($key->getKey(), $flags, $perm, $memsize))) { throw new \RuntimeException("Unable to attach shm resource {$key}"); } diff --git a/tests/Shm/SharedMemoryBlockTest.php b/tests/Shm/SharedMemoryBlockTest.php new file mode 100644 index 0000000..a1b794a --- /dev/null +++ b/tests/Shm/SharedMemoryBlockTest.php @@ -0,0 +1,25 @@ +assertEquals(11, $shm->write("Hello World", 0)); + $this->assertEquals("Hello World", $shm->read(11, 0)); + $this->assertEquals(3, $shm->write("foo", 2)); + $this->assertEquals("Hefoo World", $shm->read(11, 0)); + + $shm->destroy(); + } +} \ No newline at end of file