-2
if (fork() == 0) {
printf("Here comes the directory listing\n");
execlp("/bin/ls","ls",NULL);
printf("That is the end of the listing\n");
} else {
... /*----Some legal stuff here */
}
誰能告訴我這段代碼有什麼問題嗎?以下代碼段有什麼問題?
你曾面臨什麼問題? – 2014-12-11 05:12:47
除非exec執行失敗,否則'printf(「這是列表的結尾\ n」);'不會被打印出來。它算作「錯誤」嗎? – 2014-12-11 05:13:23
如果你想在'/ bin/ls'完成時取回控制權,你可能需要'system'。 – cHao 2014-12-11 05:15:07