Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to simulate process/daemon crash on OSX?

How can I invoke/simulate process/daemon crash on OSX and as result to receive crash report in

/Library/Logs/DiagnosticRepors

(e.g. opendirectoryd_2013-06-11-125032_macmini61.crash)?

I tried to make force quit for daemons using Activity Monitor but didn't receive any report. I need to crash some system or third party process (NOT developed by myself).

like image 526
Steven Koposov Avatar asked Jun 13 '13 11:06

Steven Koposov


2 Answers

You can force almost any process to crash by sending it a "segmentation violation" signal.

Example: Find process id of "opendirectoryd":

$ ps -ef | grep opendirectoryd
    0    15     1   0  9:14am ??         0:01.11 /usr/libexec/opendirectoryd
          ^-- process id

Send signal to the process:

$ sudo kill -SEGV 15

This terminates the process and causes a diagnostic report to be written, as can be verified in "system.log":

Oct 31 09:17:17 hostname com.apple.launchd[1] (com.apple.opendirectoryd[15]): Job appears to have crashed: Segmentation fault: 11
Oct 31 09:17:20 hostname ReportCrash[420]: Saved crash report for opendirectoryd[15] version ??? (???) to /Library/Logs/DiagnosticReports/opendirectoryd_2013-10-31-091720_localhost.crash

But note that deliberately crashing system services might cause severe problems (system instability, data loss, ...), so you should know exactly what you are doing.

like image 93
Martin R Avatar answered Oct 09 '22 16:10

Martin R


Unless you can find a legitimate bug and get it to crash that way, you can't externally crash a daemon in such a fashion that it will result in a diagnostic report. All of the quit-forcing functions are exempt from diagnostic reports as they are external issues.

like image 43
gaige Avatar answered Oct 09 '22 16:10

gaige