LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1738|回复: 3

exit(0) exit(1)...的都是什么意思?

[复制链接]
发表于 2005-6-21 00:59:22 | 显示全部楼层 |阅读模式
初学LINUX下编程,看到书上给出的程序里都有exit(0) exit(1)...的返回?语句,到底具体的意思是什么啊?括号里面的1、2。。。是什么意思啊?
大家看在我凌晨发帖子的面子上,给解答一下啊。  :-)
发表于 2005-6-21 09:18:54 | 显示全部楼层
这是程序返回给系统的状态码,具体含义由程序自己定义。一般返回0表示正常,返回大于0的数表示错误代码。
回复 支持 反对

使用道具 举报

发表于 2005-6-21 11:25:50 | 显示全部楼层
而且前边一般用perror打印错误信息
回复 支持 反对

使用道具 举报

发表于 2005-6-21 11:52:59 | 显示全部楼层
NAME
       `exit'--end program execution

SYNOPSIS
            #include <stdlib.h>
            void exit(int CODE);

DESCRIPTION
       Use `exit' to return control from a program to the host operating envi-
       ronment.  Use the argument CODE to pass an exit status to the operating
       environment:  two particular values, `EXIT_SUCCESS' and `EXIT_FAILURE',
       are defined in  ``stdlib.h''  to  indicate  success  or  failure  in  a
       portable fashion.

          `exit'  does  two  kinds  of cleanup before ending execution of your
       program.  First, it calls all application-defined cleanup functions you
       have enrolled with `atexit'.  Second, files and streams are cleaned up:
       any pending output is delivered to the host system, each open  file  or
       stream is closed, and files created by `tmpfile' are deleted.

RETURNS
       `exit' does not return to its caller.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表