What is correct way to have single Signal Handler function for multiple Signals?

前端 未结 3 1477
野趣味
野趣味 2021-01-02 07:03

What is the best way in C on Linux for setting up a program that can handle multiple POSIX-signals with the same function?

For example in my code I have a handler fu

3条回答
  •  天涯浪人
    2021-01-02 07:15

    Is this the correct way to set up this type of handling?

    Not quite - it's not safe to use printf() inside a signal handler, but you can still use write() to stdout or stderr.

提交回复
热议问题