Generating key for shmget() with using ftok() - HP UX

This is a discussion on Generating key for shmget() with using ftok() - HP UX ; > uname -smrsv HP-UX B.11.23 U ia64 Several users need to create segments of shared memory. Duplicate keys must be avoided. Does '(valid) usage of ftok()' guaranty that? It seems that the following actions should be done: A1) Create some ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Generating key for shmget() with using ftok()

  1. Generating key for shmget() with using ftok()

    > uname -smrsv
    HP-UX B.11.23 U ia64


    Several users need to create segments of shared memory. Duplicate keys
    must be avoided.
    Does '(valid) usage of ftok()' guaranty that?

    It seems that the following actions should be done:
    A1) Create some file (and not delete it),
    A2) Generate key with using ftok().

    The questions:
    Q1) Should somebody manage naming and creating such files?
    Q2) Are there any (underwater) reefs while using ftok()?


    Alex Vinokur
    email: alex DOT vinokur AT gmail DOT com
    http://mathforum.org/library/view/10978.html
    http://sourceforge.net/users/alexvn

  2. Re: Generating key for shmget() with using ftok()

    On Apr 17, 11:49*am, Alex Vinokur
    wrote:
    > > uname -smrsv

    >
    > HP-UX B.11.23 U ia64
    >
    > Several users need to create segments of shared memory. Duplicate keys
    > must be avoided.
    > Does '(valid) usage of ftok()' guaranty that?

    [sniped]

    Once more question.
    Can we use a name of some system file as ftok()'s input?
    For instance, ftok.exe itself?


    Alex Vinokur
    email: alex DOT vinokur AT gmail DOT com
    http://mathforum.org/library/view/10978.html
    http://sourceforge.net/users/alexvn



  3. Re: Generating key for shmget() with using ftok()

    Alex Vinokur wrote:
    > Duplicate keys must be avoided.
    > Does '(valid) usage of ftok()' guaranty that?


    Provided separate (permanent) files and IDs are used.

    > Q1) Should somebody manage naming and creating such files?


    Yes. Or use the executable if only one, or some common file.

    > Q2) Are there any (underwater) reefs while using ftok()?


    Like what?

    > Can we use a name of some system file as ftok()'s input?
    > For instance, ftok.exe itself?


    Better to have it controlled by the user application space.
    What ftok.exe? ftok(3) is a libc call and that could be patched often.
    I suppose you could use /stand/vmunix.

+ Reply to Thread