Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是int puts(const char*);重入吗?我可以安全地将它放入信号处理程序吗?
int puts(const char*);
下表列出了所有被认为对信号处理安全的函数:
“下表定义了一组功能,这些功能应可重入或不可被信号中断,并且应是异步信号安全的。”
puts似乎不在该列表中,但是根据this,它被认为是可重入的,但不是异步安全的,也许是为什么它不在上述列表中。
puts
不,不是,但是您可以使用write()异步信号安全的 来从信号处理程序输出消息:
write()
#include <unistd.h> const char* msg = "The message to print."; write(STDOUT_FILENO, msg, strlen(msg));