exit


setnonblocking - 设置句柄为非阻塞方式
*/
int setnonblocking(int sockfd)
{
    if (fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFD, 0)|O_NONBLOCK) == -1) {
        return -1;
    }
    return 0;
}
/*
atexit(do_at_exit);终止注册函数 对于exit适用,但是
void do_at_exit(void)
{
 printf("You can see the output when the program terminates\n");
}


int main(){
 int flag;

 flag=atexit(do_at_exit);

 if (flag != 0) {
  printf("Cannot set exit function\n");
   return EXIT_FAILURE;
 }
       
   _exit(EXIT_SUCCESS);
}
将不会打印出printf("You can see the output when the program terminates\n");
exit 和_exit 函数用于正常终止一个程序:_exit 立即进入内核,exit 则先执行一些清除处理(包括调用执行各终止处理

程序,关闭所有标准I / O 流等),然后进入内核。

进程的终止方式:   有8种方式使进程终止,其中前5种为正常终止,它们是  
 1:从 main 返回   2:调用 exit  
 3:调用 _exit 或 _Exit   4:最后一个线程从其启动例程返回  
 5:最后一个线程调用 pthread_exit

 异常终止有3种,它们是   6:调用 abort   
7:接到一个信号并终止   8:最后一个线程对取消请求做出响应

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值