ISO-C Programming Languages의 exit() 함수의 정의에 보면 다음과 같은 말이 있습니다.
Quote:
5. Finally, control is returned to the host environment. If the value of status
is zero or EXIT_SUCCESS, an implementation-defined form of the status successful termination is returned. If the value of status is EXIT_FAILURE, an implementation-defined form of the status unsuccessful termination is returned. Otherwise the status returned
is implementation-defined.
즉, 성공했을때는 0을 넘겨준다고 써있고 그렇지 않을 경우에는 다른 값을 넘겨준다고
써있네요.
3 The value of errno is zero at program startup, but is never set to zero by any library
function.170) The value of errno may be set to nonzero by a library function call
whether or not there is an error, provided the use of errno is not documented in the
description of the function in this International Standard.
170) Thus, a program that uses errno for error checking should set it to zero before a library function call,
then inspect it before a subsequent library function call. Of course, a library function can save the
value of errno on entry and then set it to zero, as long as the original value is restored if errno’s
value is still zero just before the return.
errno 값은 글로벌하게 정의가 되어 있는 것이고, 이 값은 error가 발생하지
않을 경우 결코 지워지지 않는다라고 책(APUE)에서 읽었던 기억이 나네요.
따라서 error가 발생했을것 같은 경우에만 이 errno 값을 검사하는 작업을
수행해야 하고요. error가 발생하지 않았을때 이 값을 읽는다면 아마 이전에
발생했었던 errno 값이 들어가 있을 거 같습니다.
ISO-C Programming Languages의 exit() 함수의
ISO-C Programming Languages의 exit() 함수의 정의에 보면 다음과 같은 말이 있습니다.
즉, 성공했을때는 0을 넘겨준다고 써있고 그렇지 않을 경우에는 다른 값을 넘겨준다고
써있네요.
------------------------------
좋은 하루 되세요.
[code:1]3 The value of errno is zero a
호출이 성공했을 때 errno를 0으로 리셋시키지는 않습니다.
..
errno 값은 글로벌하게 정의가 되어 있는 것이고, 이 값은 error가 발생하지
않을 경우 결코 지워지지 않는다라고 책(APUE)에서 읽었던 기억이 나네요.
따라서 error가 발생했을것 같은 경우에만 이 errno 값을 검사하는 작업을
수행해야 하고요. error가 발생하지 않았을때 이 값을 읽는다면 아마 이전에
발생했었던 errno 값이 들어가 있을 거 같습니다.
댓글 달기