How do I know my Q-KEY is unique ?
Guy Harris
guy at auspex.auspex.com
Sun Sep 24 10:12:15 AEST 1989
>There is no way to "register" or reserve an IPC key value. Most software
>that I have seen using ipc's has used one of the following:
>
> [methods 1, 2, 3, and 4]
5. Pick some file as a "rendezvous" point, and use "ftok".
To quote the SunOS 4.0 version of the "ftok" manual page:
All interprocess communication facilities require the user
to supply a key to be used by the msgget(2), semget(2), and
shmget(2) system calls to obtain interprocess communication
identifiers. One suggested method for forming a key is to
use the ftok() subroutine described below. Another way to
compose keys is to include the project ID in the most signi-
ficant byte and to use the remaining portion as a sequence
number. There are many other ways to form keys, but it is
necessary for each system to define standards for forming
them. If some standard is not adhered to, it will be possi-
ble for unrelated processes to unintentionally interfere
with each other's operation. Therefore, it is strongly sug-
gested that the most significant byte of a key in some sense
refer to a project so that keys do not conflict across a
given system.
More information about the Comp.unix.wizards
mailing list