ChinaUnix.net
相关文章推荐:

exit exit atexit

请大家一起讨论如下两个话题: 1、在main中,exit()和_exit()的区别,atexit()有什么用,atexit()函数的参数是什么,如何登记和调用的? 2、在main中,return,return(int)和main函数隐式返回的区别?

by 蓝色键盘 - C/C++ - 2003-05-12 20:36:39 阅读(8733) 回复(7)

相关讨论

1. assert() assert宏的原型定义在assert.h>中,其作用是如果它的条件返回错误,则终止程序执行,原型定义: #include assert.h> void assert( int expression ); assert的作用是现计算表达式 expression ,如果其值为假(即为0),那么它先向stderr打印一条出错信息,然后通过调用 abort 来终止程序运行。 请看下面的程序清单badptr.c: #include stdio.h> #include assert.h> #include stdlib.h> int main( void ) { FILE...

by skyily - Linux文档专区 - 2009-09-07 18:25:43 阅读(1504) 回复(0)

摘要:本文详细讲述了几个出错处理的函数abort、exit、atexit、strerror函数的使用方法,并给出来具体的示例程序。 函数名: abort 功 能: 异常终止一个进程 用 法: void abort(void); 头文件:#include 说明:abort函数是一个比较严重的函数,当调用它时,会导致程序异常终止, 而不会进行一些常规的清除工作,比如释放内存等。 程序例: #include #include int main(void) { puts( "About to abort....\n" ); a...

by iceway - Linux文档专区 - 2008-10-16 09:21:47 阅读(800) 回复(0)

关于调用exit退出 疑惑:若在一个子进程中调用exit是只是结束了该子进程,后续的子进程在内核中的相关数据 是系统函数清理??还是调用exit函数来清理啊?、

by tc1989tc - Linux环境编程 - 2013-01-08 18:40:54 阅读(1091) 回复(4)

大家好,我是新手。请大家看代码: #include #include #include #include int glob = 6; /* external variable in initialized data */ int main(void) { int var; /* automatic variable on the stack */ pid_t pid; var = 88; printf("before vfork\n"); /* we don't flush stdio */ if ((pid = vfork()) < 0) { printf("v...

by ooaoodoop1 - C/C++ - 2012-06-03 23:50:00 阅读(993) 回复(7)

大家好,我是新手。请大家看代码: #include #include #include #include int glob = 6; /* external variable in initialized data */ int main(void) { int var; /* automatic variable on the stack */ pid_t pid; var = 88; printf("before vfork\n"); /* we don't flush stdio */ if ((pid = vfork()) < 0) { printf("vf...

by ooaoodoop1 - Linux环境编程 - 2012-06-04 19:58:33 阅读(1442) 回复(7)

请问,这两个有什么不同。 有的说后者带下划线的退出不负责关闭一些打开的描述符。 也就是说使用后者会造成资源浪费。 那岂不是说如果我的程序频繁调用后者结束,无数次后,机器资源岂不耗尽了。 不知道是不是。 还有windows和Linux这两个函数是一样吗?

by urapple - C/C++ - 2011-06-10 21:41:16 阅读(3888) 回复(11)

在pthread里call这两个函数,行为很怪异,下面慢慢道来 今天出了一个core,gdb一看这个core是由exit调用引起的,该exit是在一个pthread中调用的,于是查了一些资料,写了一些测试例子,但还是不能很圆满地解释,因此发帖询问。 问题描述:在线程中,先调用了printf打印一个字符串,由于异常情况,传入的指针在合法的范围内没有0,因此printf可能访问越界了,printf之后是一个exit函数,exit执行时程序core dump了,原因猜测可能是p...

by tianqio - C/C++ - 2008-03-14 14:20:39 阅读(1460) 回复(0)

区别: exit: 该函数是由ISO定义的,该函数会调用由atexit注册的所有exit handlers,关闭所有打开的标准I/O流被flush和closed。删除临时文件。(由temfile创建) 简单的说,exit函数将终止调用进程。在退出程序之前,所有文件关闭,缓冲输出内容将刷新定义,并调用所有已刷新的“出口函数”(由atexit定义)。 _exit:该函数是由Posix定义的,不会运行exit handler和signal handler,在UNIX系统中不会flush标准I/O流。 简单的说,...

by zxbjlu1983 - Linux文档专区 - 2006-08-24 15:55:51 阅读(586) 回复(0)

... if (0 == (pid1 = fork())) { if (0 == (pid2 = fork())) //in process(pid2), pid2 is the child of pid1. { execlp(...); goto error_exec; } else if (pid2 > 0) // in process(pid1) { exit(0); } else // in process(pid1) goto error_fork2; } else if (pid1 > 0) { waitpid(pid1, &status, 0); ... } else goto error_fork1; ... 请教一下,为什么...

by horizonwind - Linux环境编程 - 2013-11-26 10:24:03 阅读(897) 回复(5)

exit(1)执行之后怎么就退出程序了?下面的程序还没有执行呢.. 比如 if(....) { .... exit(1);//出错了,返回出错信息,但是怎么就不执行下面的while了呢?费解 } while() { .....} 具体的程序如下.麻烦帮解释下.太有问题了............... #include ; #include ; #include ; #include ; #include ; #include ; #include ; #define BUFFER_SIZE 1024 ...

by dianlongliu - C/C++ - 2008-04-03 15:43:07 阅读(1685) 回复(6)