我正在使用GCC编译器在Linux上工作.当我的C++程序崩溃时,我希望它能自动生成一个堆栈跟踪.
我的程序由许多不同的用户运行,它也可以在Linux,Windows和Macintosh上运行(所有版本都使用编译gcc).
我希望我的程序能够在崩溃时生成堆栈跟踪,并且在用户下次运行它时,它会询问他们是否可以将堆栈跟踪发送给我,以便我可以追踪问题.我可以处理向我发送信息,但我不知道如何生成跟踪字符串.有任何想法吗?
如何将int(整数)转换为字符串?我正在尝试创建一个函数,将a的数据struct转换为字符串以将其保存在文件中.
itoa()是一个非常方便的函数,可以将数字转换为字符串.Linux似乎没有itoa(),是否有相同的功能或我必须使用sprintf(str, "%d", num)?
由于printf不是可重入的,因此在信号处理程序中使用它并不安全.但我已经看到很多使用printf这种方式的示例代码.
所以我的问题是:我们何时需要避免printf在信号处理程序中使用,是否有推荐的替代品?
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.
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)