免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: chdonald
打印 上一主题 下一主题

_exit和exit的区别? (无内容) [复制链接]

论坛徽章:
0
31 [报告]
发表于 2005-04-18 09:25 |只看该作者

_exit和exit的区别? (无内容)

周末生了一场大病,差点死掉,唉,也没研究这个

高手们来指点一些啊,Linux的exit调用的_IO_cleanup()为什么没起作用呢?

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
32 [报告]
发表于 2005-04-18 09:26 |只看该作者

_exit和exit的区别? (无内容)

原帖由 "albcamus" 发表:
周末生了一场大病,差点死掉,唉,也没研究这个

高手们来指点一些啊,Linux的exit调用的_IO_cleanup()为什么没起作用呢?


要注意身体啊!

论坛徽章:
0
33 [报告]
发表于 2005-04-18 09:37 |只看该作者

_exit和exit的区别? (无内容)

原帖由 "aero" 发表:


要注意身体啊!


唔,谢谢兄弟   

论坛徽章:
0
34 [报告]
发表于 2005-04-18 15:39 |只看该作者

_exit和exit的区别? (无内容)

我在Digital UNIX下执行一样有printf得输出

论坛徽章:
0
35 [报告]
发表于 2005-04-20 04:01 |只看该作者

_exit和exit的区别? (无内容)

一般地说, fork()以后, 我们会很快在子进程中exec(). 特别是vfork().这个函数就是为这种应用而设的.

想调查一下, 有没有谁在实践中, fork()以后, 在子进程中不exec(), 而后exit(0)或_exit()呢?

论坛徽章:
0
36 [报告]
发表于 2005-04-20 09:04 |只看该作者

_exit和exit的区别? (无内容)

>;>;想调查一下, 有没有谁在实践中, fork()以后, 在子进程中不exec(), 而后exit(0)或_exit()呢?

vfork的设计,子进程exec和exit都是put一个信号量,对父进程来说,是一样的。

论坛徽章:
0
37 [报告]
发表于 2005-04-20 09:16 |只看该作者

_exit和exit的区别? (无内容)

原帖由 "albcamus" 发表:
>;>;想调查一下, 有没有谁在实践中, fork()以后, 在子进程中不exec(), 而后exit(0)或_exit()呢?

vfork的设计,子进程exec和exit都是put一个信号量,对父进程来说,是一样的。



等待答案

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
38 [报告]
发表于 2005-07-17 08:10 |只看该作者

_exit和exit的区别? (无内容)

这篇帖子还是没有结果.
>;>;高手们来指点一些啊,Linux的exit调用的_IO_cleanup()为什么没起作用呢?

这个是为什么?

论坛徽章:
0
39 [报告]
发表于 2005-07-17 12:21 |只看该作者

_exit和exit的区别? (无内容)

  1. #include <stdio.h>;

  2. int main()
  3. {
  4.     printf("%c", 'c');
  5.     _exit(0);
  6. }
复制代码

程序并没有输出"c", 说明_exit()没有进行io flush

论坛徽章:
0
40 [报告]
发表于 2005-07-17 16:24 |只看该作者

_exit和exit的区别? (无内容)

From POSIX programmers' guide


Calling exit()
The exit() function causes normal program termination. The EXIT_SUCCESS macro can
be used to indicate successful termination. Since the POSIX standard requires that
EXIT_SUCCESS be defined as zero, it is safe to write exit(0), keeping with historical
practice. The call exit(0) is extremely portable.
The exit() function performs the following functions:
1. All functions registered by the Standard C atexit() function are called in the reverse
order of registration. If any of these functions calls exit(), the results are not portable.
2. All open output streams are flushed (data written out) and the streams are closed.
3. All files created by tmpfile() are deleted.
4. The _exit() function is called.

Calling _exit()
The _exit() function performs operating system-specific program termination functions.
These include:
1. All open file descriptors and directory streams are closed.
2. If the parent process is executing a wait() or waitpid(), the parent wakes up and
status is made available.
3. If the parent is not executing a wait() or waitpid(), the status is saved for return to
the parent on a subsequent wait() or waitpid().
4. Children of the terminated process are assigned a new parent process ID. Note: the
termination of a parent does not directly terminate its children.
5. If the implementation supports the SIGCHLD signal, a SIGCHLD is sent to the parent.
6. Several job control signals are sent.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP