errno
函式原型
#include <errno.h>
int errno;說明
傳回值
範例
s = socket(PF_INET, SOCK_STREAM, 0);
if (s == -1) {
perror("socket"); // 或者使用 strerror()
}
tryagain:
if (select(n, &readfds, NULL, NULL) == -1) {
// 發生錯誤!!
// 如果我們只有被中斷,則只需重新啟動 select() call:
if (errno == EINTR) goto tryagain; // AAAA! goto!!!
// 否則,就是個嚴重的錯誤:
perror("select");
exit(1);
}參考
Last updated