我有一个 C++ 应用程序,它使用我试图通过 PHP“exec”命令调用的信号量。从终端以“root”身份登录时,我可以成功运行该应用程序,但是当 apache 尝试运行它(作为用户 apache)时,它会失败并出现“Permission denied”错误。
我做了一个“chwon apache:apache prog”和777它的权限来测试,它仍然失败。
奇怪的是,这个确切的应用程序在我的本地开发环境中通过 apache 运行得非常好。两个环境都是 Centos 6.4 (Final) x86_64 并以同一用户身份运行 PHP。
我没有想法,我不确定我还能做什么。
这是我的代码的相关部分。
void landw(char* path, char* retType)
{
startLocking:
int semid,count;
struct sembuf op;
semid = semget((key_t)KEY,10,0666|IPC_CREAT);//Fails here
if(semid==-1)
{
perror("error in creating semaphore, Reason:");
}
...
我什至已将“semget”行更改为测试,但仍然不行。
semid = semget((key_t)KEY,10,0666|IPC_CREAT|S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
谢谢