Chinaunix首页 | 论坛 | 博客
  • 博客访问: 119014
  • 博文数量: 41
  • 博客积分: 1695
  • 博客等级: 上尉
  • 技术积分: 430
  • 用 户 组: 普通用户
  • 注册时间: 2006-10-21 22:50
文章分类

全部博文(41)

文章存档

2010年(1)

2007年(23)

2006年(17)

我的朋友

分类: C/C++

2007-04-26 16:16:35

exit()在结束调用它的进程之前,要进行如下步骤:
1.cleanup();
2.在atexit()注册的函数;
最后调用_exit()函数

#include
#include
#include

int main(int argc, char *argv[])
{
    pid_t pid;
    
    printf("test me!\n"); 
    pid = fork();
    if (pid > 0) {
        wait(NULL);
        _exit(0);
    }  
    else {
        _exit(0);
    }  
}

$a.out
guorh@maomao:~/code/aupex$ a.out
test me!
guorh@maomao:~/code/aupex$ a.out > tmp
guorh@maomao:~/code/aupex$ cat tmp
tmp中没有任何字符,因为_exit直接进入内核退出,没有刷新缓存。


 
阅读(2763) | 评论(1) | 转发(0) |
0

上一篇:FIFO通信

下一篇:FIFO例子

给主人留下些什么吧!~~