key是一个索引,要去内核当中找到相关ID队列,并且返回队列ID
fork()函数 :
1.系统IPC键值的格式转换函数
2.系统建立IPC通讯时(消息队列、共享内存、信号量),必须指定一个ID值,该ID值通过ftok()得到
1 #include<sys/ipc.h>
2 #include<stdio.h>
3 // key_t ftok(const char *pathname, int proj_id);
4
5 int main()
6 {
7 key_t key;
8 key = ftok(".",'G');
9 printf("key=%d\n",key);
10 printf("key=%x\n",key);
11 return 0;
12 }
~
ls -a
ls -i 查看文件索引结点号
ls -ai