Proper usage of volatile sig_atomic_t

前端 未结 1 1550
栀梦
栀梦 2020-12-03 05:52

According to this site, one can use variables of type volatile sig_atomic_t inside a signal handler. Now my question is, would for example something like the fo

相关标签:
1条回答
  • 2020-12-03 06:08

    Unless your program is multithreaded, signal handlers never run concurrently with other code in your program, and they certainly never run concurrently with the code they've interrupted. Your code is fine as long as the signal sig is masked for the duration of the signal handler.

    0 讨论(0)
提交回复
热议问题