c - perror 是线程安全的吗?

标签 c linux unix posix posix-api

我知道 errno 是线程安全的。而在Linux中,还有另外2个类似的函数,分别是strerror和strerror_r。根据 Robert Lover 的书 Linux System Programming,strerror 不是线程安全的,但 strerror_r 是。所以我想知道 perror 是否是线程安全的。

最佳答案

在 POSIX 系统(如 Linux)中,perror 是线程安全的。

perror 在这里没有列为非线程安全:

All functions defined by this volume of POSIX.1-2008 shall be thread-safe, except that the following functions1 need not be thread-safe. [...]

http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html

关于c - perror 是线程安全的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24899502/

相关文章:

python - 在 Python 中将整数列表解释为 float

c - super 奇怪的问题触发 "Segmentation Fault"

php - 自定义 cron 作业未安排 Magento2

unix - unix 中两个文件的左外连接

shell - Unix:打印文件夹中每个文件的文件名和每行超过80个字符的行号

c++ - c递归程序问题

c - 在C程序中发送ICMP数据包

java - 在 Linux 中获取用户进程的执行时间

c++ - Google Filament渲染引擎分割错误

c - 如何运行这个程序?