2016-01-10 95 views
-1

創建生產者/消費者系統。製片人是爲了呼籲消費者,但我得到的錯誤Execl Permission Denied

execl failed for producer: Permission denied 

這裏是呼叫:

if (execl("/home/aaron/Documents/Programming/c/producerAsignment", 
      "runConsumer", NULL) == -1) { 

    perror("execl failed for producer"); 
    exit(3); 
} 

我試圖把可執行文件到同一目錄下的程序調用,但這沒有什麼區別。

ls -l /home/aaron/Documents/Programming/c/producerAsignment 
... 
-rwxrwxr-x 1 aaron aaron 8760 Jan 10 22:28 runConsumer 
... 
+1

在bash中輸入'ls -l/home/aaron/Documents/Programming/c/producerAsignment'輸出 –

+0

aaron @ aaron:〜$ ls -l/home/aaron/Documents/Programming/c/producerAsignment 共60 drwxrwxr-x 3 aaron aaron 4096 Dec 16 13:49 build drwxrwxr-x 3 aaron aaron 4096 Dec 16 13:49 dist -rw-rw-r-- 1 aaron aaron 3482 11月23日22:56 Makefile drwxrwxr-x 3 aaron aaron 4096 Nov 23 22:56 nbproject -rw-rw-r-- 1 aaron aaron 3782 Jan 10 23:00 produce.c -rwxrwxr-x 1 aaron aaron 13484 Jan 10 22:53 run -rwxrwxr-x 1 aaron aaron 8760 Jan 10 22:28 runConsumer -rwxrwxr-x 1 aaron aaron 9050 Dec 7 09:32 yellow –

+3

你在給一個目錄的名字嗎?看到這篇文章http://stackoverflow.com/questions/19414460/for-the-following-c-program-execl-returns-1-signifying-a-permission-denied-er –

回答

2

好吧,事實證明,您要執行的文件實際上是一個目錄(見在ls命令輸出的開頭字母「d」)。你不能執行目錄。只有具有執行權限的文件。

+0

非常感謝!剛剛發現了!祝你今天愉快! –

相關問題