If the signal handler is registered, no crash report is generated.

Hello


The process I have implemented runs as a daemon.

If the process is terminated forcibly, a problem of infinite re-execution occurs.

So, I registered the signal handler using the sigaction api.

When a sigsegv or sigabrt signal is received, no crash report is generated.

However, I need a crash report to know the cause of the problem.

Is there a way to solve the problem?


Thanks for reading.

Replies

I generally recommend that you avoid registering signal handlers where possible; signals are a horrible can of worms. So, let’s look at your use case. You wrote:

If the process is terminated forcibly, a problem of infinite re-execution occurs.

I don’t understand this. What do you mean by “terminated forcibly”?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thank you for your reply.


"Force terminated" means when a signal is received.

How can I prevent the daemon process from terminating repeatedly when it receives a signal?

"Force terminated" means when a signal is received.

Right, but there are lots of different signals with lots of different default dispositions. Moreover, if you’re building a daemon — and at this point I assume it’s a launchd daemon — then some signals are special in that environment. For example, if the system wants to terminate your daemon it will send it a

SIGTERM
, and if it terminates in response to that signal then it the system won’t automatically relaunch it (because it’s actively trying to terminate it).

Please give us more details about the specific use case you’re trying to solve.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I did not have a detailed description... Sorry.

I loaded the plist by setting keepalive to true in launchd to run the daemon process.

So when the daemon process receives SIGABRT, it is re-released by launchd infinitely.

I used a signalhandler to avoid this problem.

When the daemon process receives a SIGABRT, the signalhandler unloads the plist and terminates the process.

However, a crash report is not generated when the daemon process receives SIGABRT.


Please find a way.

Why does it receive SIGABRT? If it gets relaunched, why would it get SIGABRT again (and thus relaunch infinitely)?


If you don't want the daemon to be relaunched, why are you setting the keepalive property? Have you tried using a dictionary of conditions as the value for keepalive and, in that dictionary, setting the Crashed property to false? That seems like exactly what you want.

In addition to what Ken Thomases asked, I’m curious about the following:

So when the daemon process receives

SIGABRT

Is this

SIGABRT
being generated asynchronously? Or by someone calling
abort
?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"