ffttookk() -- General Function (libc)

Generate keys for interprocess communication
#iinncclluuddee <ssyyss/ttyyppeess.hh>
#iinncclluuddee <ssyyss/iippcc.hh>
kkeeyy_tt ffttookk(_f_i_l_e_n_a_m_e, _p_r_o_c_i_d)
cchhaarr *_f_i_l_e_n_a_m_e;
cchhaarr _p_r_o_c_i_d;

The  COHERENT system  implements  three methods  by which  one process  can
communicate with another: semaphores, messages, and shared memory.  In each
case, a  process must use a  key of type kkeeyy_tt (which  is defined in header
file <ssyyss/ttyyppeess.hh>) to identify itself.

One problem is that each process  generates its own key, by its own method.
Therefore, two  processes could independently generate  the same key, which
could create serious problems for interprocess communication.

The function ffttookk()  generates keys for processes that perform interprocess
communication.  _f_i_l_e_n_a_m_e is the full path  name of a file.  This can be the
full path name of the file  in which the program resides on disk.  The file
named in _f_i_l_e_n_a_m_e must exist and  be accessible for the system call ssttaatt(),
or ffttookk() will fail.  _p_r_o_c_i_d  is a one-character identifier with which this
process distinguishes  itself from all  other processes that  are pegged to
_f_i_l_e_n_a_m_e. How a process generates _p_r_o_c_i_d is up to the program itself.

For example, the  program mmyypprroocc can generate a unique  key for itself with
the call:

    key_t mykey;
    mykey = ftok("/usr/bin/myproc", 'A');

Note the following caveats:

-> Because ffttookk()  generates its key  from a file's i-node  major and minor
   numbers rather  than its name, it  generates the same key  for two files
   that   are   linked.   For   example,   if   files  /uussrr/hheennrryy/ffoooo   and
   /uussrr/hheennrryy/bbaarr are linked to each other, then the calls

       ftok("/usr/henry/foo", 'A');

   and

       ftok("/usr/henry/bar", 'A');

   will generate the same key.

-> If the file named by _f_i_l_e_n_a_m_e  is destroyed and then recreated, the call
   to  ffttookk() generates  a different  key than it  did before  _f_i_l_e_n_a_m_e was
   destroyed.

-> If the file named by _f_i_l_e_n_a_m_e does not exist, ffttookk() returns (kkeeyy_tt) -11.

_E_x_a_m_p_l_e
For an example of this function, see the entry for mmssggggeett().

_S_e_e _A_l_s_o
iippcc.hh, lliibbcc, mmssggggeett(), sseemmggeett(), sshhmmggeett()
