现在的位置: 首页 > 综合 > 正文

vkfork死循环

2013年06月13日 ⁄ 综合 ⁄ 共 504字 ⁄ 字号 评论关闭

实例:

               

这么一个简单的小程序,当把里面的exit(0),改为return 0,就会出现未定义的结果。

then Why?

The vfork() function shall be equivalent to fork(), except that the behavior 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.
调用vfork()之后,子进程要么_exit(),要么调用某个exec(),否则都是未定义行为!
注意:
This function is marked obsolescent.(这个函数式荒废了的),呵呵,所以不必纠结了。。。。。。。。。

抱歉!评论已关闭.