exec 函數用於在目前的 process 中啟動一個新的程式,取代目前 process 的執行。
也就是成功執行後,原來的程式碼將不再執行,因為目前 process 已被新程式取代。
如果要繼續執行原本的程式,可以使用 fork 讓 exec 在 child process 中執行
以下為使用 execvp 的程式碼
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Are you sure to leave this team?
Once you delete your team, all team notes will be deleted and cannot be recovered. Please ensure you've exported or transfered these notes.
Enter team name before deleting it:
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up