English 中文(简体)
与IPC_CREAT一起返回
原标题:shmget() returns ENOENT with IPC_CREAT

使用<代码>shmget(>)分配一个共享记忆部分,然后用<代码>pthread_mutex_init(创建一种程序间共享的传承。 一般来说,这项工作是按预期进行的。 但是,<代码>shmget(>>将返回<>ENOENT。 阅读人页,只有在<代码>shmflg的情况下才能这样做。 不包括<代码>IPC_CREAT。 我也这样做。 这里是我守则的主轴:

shmid_ = shmget( MYLOCK_KEY_ID, sizeof(pthread_mutex_t), IPC_CREAT | IPC_EXCL | 0666 );
if ( errno == ENOENT ) {
    // This should never occur since IPC_CREAT was specified
    std::cerr
       << "shmget() returned ENOENT (it thinks IPC_CREAT wasn t  specified).
"
       << "This seems to be a bug in shmget()?" << std::endl;
    exit(1);
}

我完全失去了可以做些什么。 我在几个系统上尝试了这一问题(HCB kernels 2.6.32和3.3.5),但两者都表现出同样的行为。 目前,当我获得这种失败模式时,我只是重复这一进程,而且通常工作。 但是,这似乎是一种判决,我不知道这在<条码>中是否是一种泡沫?

任何想法?

最佳回答

如果说不核对回扣价值的话,那页人就说要检查一把双mid,然后检查耳机。

RETURN VALUE 
A valid segment identifier, shmid, is returned on success, -1 on error.

你正在做的是检查频率,在其他一些职能失败后,这可能是ENOENT。

问题回答

暂无回答




相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签