在Linux中如何处理errno和信号处理程序? [英] How to deal with errno and signal handler in Linux?
本文介绍了在Linux中如何处理errno和信号处理程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我们编写一个可能更改errno的信号处理程序时,是否应该在信号处理程序的开头保存errno并在其末尾恢复errno?如下所示:
When we write a signal handler that may change the errno, should we save errno at the beginning of the signal handler and restore the errno at the end of it? Just like below:
void signal_handler(int signo){
int temp_errno = errno;
*** //code here may change the errno
errno = temp_errno;
}
推荐答案
查看全文