最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

linux - async-signal safety of c++ classes - Stack Overflow

programmeradmin1浏览0评论

There is a limited number of functions that POSIX defines as async-signal safe. See here.

This includes some fundamental functions such as write.

Since this is really a C standard (since unix is built on C) that makes no mention of C++, I would expect this to be undefined, but the question is: can I use any c++ functions or classes (which involve constructors/destructors etc) inside a signal handler? For example: can I construct a std::string or std::pair?

malloc is not on the list of async-signal safe functions, so it is probably safe to assume that the potential memory allocation used by std::string makes it async-signal unsafe in the general sense (?).

发布评论

评论列表(0)

  1. 暂无评论