我正在c下开发需要通过共享内存进行通讯的应用。我需要通过应用程序中的某些字段来生成密钥,因此我只是将它们转换为int并调用了ftok,但是它不起作用,我也不知道为什么。
导致错误的代码:
int proj_id = 3001; // it's calculated by app, basicly it just convert a few fields into unique int for example 3001
key_t key;
if((key = ftok(".", proj_id)) < 0);
{
perror("ftok");
return -1;
}
输出:ftok:资源暂时不可用
但是我经常遇到这个问题。您是否知道为什么以及如何解决?预先感谢! ;)
错误检查应该是: