创建核心转储时设置退出状态
例如,调用 exit(100)
会以状态 100 退出应用程序,而调用 raise(SIGABRT)
会在创建核心转储时以状态 134 中止应用程序。但是,如果我想要状态为 100 或任何其他任意值的核心转储怎么办?我怎样才能做到这一点?我知道有几个信号会触发核心转储,但它们似乎有固定的退出状态。
For example calling exit(100)
would exit the application with status 100, and calling raise(SIGABRT)
aborts the application with status 134 while creating a core dump. But what if I want the core dump with status 100 or any other arbitrary value. How can I do that ? I know there are several signals that triggers a core dump, but they seem to have fixed exit statuses.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来
134
等于(128+6)
并且等于((1<<7) | 6)
(其中#定义 SIGABRT 6
)巧合?
Looks like
134
equals to(128+6)
and euqals to((1<<7) | 6)
(where#define SIGABRT 6
)Co-incidence?
好吧,我想你可以
fork()
并让父进程调用_exit(100)
,让子进程调用abort()
...不过,我同意这些评论,认为这是一个坏主意。
Well, I suppose you could
fork()
and have the parent call_exit(100)
, and the child callabort()
...I concur with the comments saying that it's a bad idea, though.