手冊頁似乎沒有說明這是如何完成的。我很困惑,特別是因為這里的這條線:The argv[] and envp[] arrays of pointers and the strings to which those arrays point shall not be modified by a call to one of the exec functions, except as a consequence of replacing the process image.
是否在替換程序映像之前將引數陣列復制到某處?該行似乎暗示它們總是被修改,因為程序映像總是被替換。
我看到該檔案還說以下內容:The statement about argv[] and envp[] being constants is included to make explicit to future writers of language bindings that these objects are completely constant.
我覺得這可以幫助我理解,但我不完全確定他們在這里所說的內容是不變的。
另外我想知道為什么c_str()在.std::stringexecvp()argv
謝謝。
uj5u.com熱心網友回復:
exec()函式可能會失敗,并回傳錯誤指示。這發生在呼叫行程中,呼叫行程繼續運行。在這種情況下,exec()簡單地失敗,就像任何其他系統呼叫一樣,open()或者read()可能失敗。這只是一個失敗的系統呼叫。
您參考的所有意思是,在這種情況下,傳入的字串exec()不會被修改。從他們的內容回傳后,呼叫本身exec()不會改變。exec()
該行似乎暗示它們總是被修改,因為程序映像總是被替換
不,程序映像并不總是被替換。如果你傳入一個exec()不存在的路徑名,很明顯它不可能被任何東西替換,并且會回傳一個錯誤。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/434302.html
