shmat() & shmdt() questions.

Dave Lee dave at dptechno.UUCP
Thu Sep 20 03:58:52 AEST 1990


In article <13783 at hydra.gatech.EDU> gt0178a at prism.gatech.EDU (BURNS,JIM) writes:
>in article <13782 at hydra.gatech.EDU>, I write:
>>    myshmid = shmget (some-made-up-not-in-use-int-id, 4096, IPC_CREAT|600);
>                                               ^^^
>
>I suppose that should actually be 'long', as in 'key_t'. I actually
>normally use an ascii representation of a 4-char string (assuming
>key_t=long). E.g. - if I want the key to be 'phs1', I use '0x70687331'.


And just how is one supposed to know what is "not-in-use" ?, unless ofcourse,
you just happen to be in controll of all the sources to all programs that 
may ever run on your machine.

If everyone would use ftok(path,id)  (see stdipc(3C)) as recomended in the FM,
(and then document the path and id used), then selecting a key would have a 
lot less chance of colliding with other program uses.  Unless you really
want a private key, then use IPC_PRIVATE.

IMHO of course.

 
-- 
Dave Lee
uunet!dptechno!dave



More information about the Comp.unix.internals mailing list