0
我試圖用fork()以非阻塞方式在程序中運行程序。fork()阻止父進程
pid = fork();
//check for errors
if (pid < 0) {
exit(1);
}
//the child process runs the gulp
if (pid == 0) {
if (execv("/home/gulpSniffer/programname", args) < 0) {
exit(1);
}
//child is supposed to block here
}
//father is supposed to continue its run from here
但是,不執行在孩子的過程塊該程序的整個程序,和父親的代碼段的調用,因爲它阻止了孩子。
有沒有人有一個想法,爲什麼?
感謝
父進程確實應該在您指定的位置運行;但子進程將* not *阻止你指定的地方 - 相反,它將被作爲參數傳遞給'execv()'的進程替換掉。 – onon15
是什麼讓你認爲父進程被阻塞? – Hasturkun
「孩子應該在這裏阻止」你顯然是說,孩子應該永遠不會到達這條線? – hyde