Re: [Linux] Shared memory and pointers

Discussion in 'C++' started by Victor Bazarov, May 14, 2012.

  1. On 5/14/2012 11:17 AM, Willy wrote:
    > I've a problem with shared memory and pointers.


    Shared memory is not defined by the language, nor is interprocess
    communication (how, for instance, memory addresses are mapped between
    two different processes, whether the memory is shared or not). You'll
    be better off asking about platform-specific elements in that platform's
    newsgroup. Try 'comp.os.linux.development.*' hierarchy.

    Good luck!

    > I've a struct like this in shm:
    >
    > typedef struct my_struct
    > {
    > char mat[3][10];
    > char * p_mat;
    > }my_struct;
    >
    > and a process A that sets:
    >
    > shm->p_mat = &shm->mat[2];
    >
    > Another process B that try to print it:
    >
    > printf("%s",shm->p_mat);
    >
    > I obtain a segmentation fault.
    >
    > I think that is not the right way to use pointers in shared memory, but
    > I can't find more info.


    V
    --
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, May 14, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Zorro
    Replies:
    3
    Views:
    543
    Venu Yanamandra
    Nov 25, 2010
  2. cerr

    pointers, pointers, pointers...

    cerr, Apr 7, 2011, in forum: C Programming
    Replies:
    12
    Views:
    674
  3. BGB
    Replies:
    0
    Views:
    466
  4. Juha Nieminen
    Replies:
    0
    Views:
    420
    Juha Nieminen
    May 15, 2012
  5. Nobody
    Replies:
    0
    Views:
    421
    Nobody
    May 16, 2012
Loading...

Share This Page