| jacamar 回复于:2002-11-05 23:32:26
|
fork后就是两个进程了,就像没有关系一样
|
| zhutr 回复于:2002-11-05 23:34:30
|
只是子进程退出, 父进程并没有退出呀! 当然要打出来了!
|
| beggar 回复于:2002-11-05 23:49:05
|
vfork和fork不同 vfork在调用exec或exit之前在父进程空间中运行且保证子进程先运行,如果子进程不调用exec或exit父进程永远得不到运行.你用vfork的子进程更改了父进程空间中的的var值,所以你会看到var值为2而不是你想要的1.用fork就能看到你想要的1
|
| JohnBull 回复于:2002-11-06 12:12:15
|
同意.
(From XPG4 / SUSv2 / POSIX draft.) The vfork() function has the same effect as fork(), except that the behaviour is undefined if the process created by vfork() either modifies any data other than a variable of type pid_t used to store the return value from vfork(), or returns from the function in which vfork() was called, or calls any other function before successfully calling _exit() or one of the exec family of functions.
|
| aiya 回复于:2002-11-06 15:13:34
|
有道理!
|