Shared memory between 2 processes???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tamagafk

    #1

    Shared memory between 2 processes???

    Hi,
    I have two running php processes (they have infinite loops) and I need
    them to pass some data to eachother. Writing and reading shared memory
    in one process works just fine but when I try to save var in process1
    and read in process2 I get error: "Variable key 555 doesn't exist".
    What I'm doing wrong?
    Here are the sources:

    //PROCESS 1 (saving var)
    $key = 'My Key';
    $value = 'My Value';
    $app = 'lovelyapp';
    $key = $key . 'a';
    $segment_key = abs(crc32($app . $key));
    $segment_size = 1024;
    $segment_perms = 0600;
    $shm_id = shm_attach($seg ment_key, $segment_size, $segment_perms) ;
    shm_put_var($sh m_id, 555, $value);
    shm_detach($shm _id);

    // PROCESS 2 (reading var)
    $key = 'My Key';
    $app = 'lovelyapp';
    $key = $key . 'a';
    $segment_key = abs(crc32($app . $key));
    $segment_size = 1024;
    $segment_perms = 0600;
    $shm_id = shm_attach($seg ment_key, $segment_size, $segment_perms) ;
    $value = shm_get_var($sh m_id, 555);
    shm_detach($shm _id);

    Thnaks!

  • Tamagafk

    #2
    Re: Shared memory between 2 processes???

    Found it by myself:


    Comment

    Working...