相关疑难解决方法(0)

如何避免在信号处理程序中使用printf?

由于printf不是可重入的,因此在信号处理程序中使用它并不安全.但我已经看到很多使用printf这种方式的示例代码.

所以我的问题是:我们何时需要避免printf在信号处理程序中使用,是否有推荐的替代品?

c linux signals

80
推荐指数
4
解决办法
3万
查看次数

My shell cannot prevent ctrl+c from killing itself

I write my own shell (source code is listed below) and set user's default shell to it.

I login with this user and type ctrl-C, and this shell is killed even though this signal is catched. However, I run this shell directly from bash, it works as I expect. What makes the difference.

Result

Login with user whose default shell is set to my own shell:

BMC login:
BMC login: naroot
Password:
BMC > signal = 2
BMC login: …
Run Code Online (Sandbox Code Playgroud)

c linux

7
推荐指数
1
解决办法
109
查看次数

标签 统计

c ×2

linux ×2

signals ×1