I have an application written with C++ and running on Solaris. The application does lots of things and sends a heartbeat to a watchdog application for saying "I am alive". If something goes wrong the application does nothing (also does not send heartbeat). In a Java app, kill -3
helps me to see what is going on. Should I implement a similar functionality MANUALLY using signals for a native (non-java) app? Or is there an开发者_如何学JAVAy alternative way to see what is going on my application internally (thread state etc).
Both Solaris and Linux support the gcore command to create a core dump of a running process. Then you can use gdb (or dbx) to analyze the core file.
The most flexible way to see what is going on in your native application is to attach a debugger and then examine whatever interests you manually.
If you terminate the application with kill -3
it will generate a core dump, which can later be manually examined with a debugger in a similar way.
If you want specific information logged/... in reaction to the signal sent by kill -3
you have to implement that yourself.
精彩评论