NS.X.
NS.X.

Reputation: 2142

Close "<app> quit unexpectedly" window from terminal/bash

Is there a way to close/kill " < app> quit unexpectedly" window from terminal or bash script? What's the process name?

(AppleScript automation solutions are not acceptible.)

Upvotes: 3

Views: 1336

Answers (3)

a3f
a3f

Reputation: 8657

You can disable it appearing in the first place by:

defaults write com.apple.CrashReporter DialogType none

Other possible values are developer (show stack traces for all processes) and crashreport (the default).

This also means that no entries will be written to the Console.app though. The dialog itself is shown by the UserNotificationCenter and can be disabled (along with many other notifications) by:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.UserNotificationCenter.plist

Some context:

Mach has a concept of exception ports. Each thread/process has a task, process and a host exception port, which are checked when an exception occurs. The CrashReporter daemon registers the host exception port and gets activated when no other signal handler ran. It then creates a stack trace and memory map of the process and instructs the UserNotificationCenter to show it. By default it only does so for GUI applications.


On High Sierra, I had to use defaults write com.apple.CrashReporter -string "developer"

Upvotes: 3

clt60
clt60

Reputation: 63972

You can:

killall UserNotificationCenter

It will kill the UserNotificationCenter (an ALL it's opened windows too), so the message disappears. (Don't worry, the next error message will start is again automatically.)

But, (IMHO) it is better to use the osascript command in a form:

osascript -l JavaScript <<EOS
... apple-scripting using JavaScript ...
EOS

IMHO JavaScript is much easier to understand (for an common programmer) as the "standard" applescript.

Upvotes: 11

Mario
Mario

Reputation: 1042

I am not sure if apple hast the same core utilities, but I come from the unix world too.

for example: the solution would be to find the process id via name. on my linux system I can use the following to find a process id...

ps -aux

An other variation would be top. both give a ton of information and I have to filter the code with grep. After that I would filter the string via cut or sed. last but not least the kill command.

the script should look some like this ...

#!/bin/sh
PNAME="< app> quit unexpectedly"
ps -aux | grep "$PNAME" | cut -d" " -f2 | kill

but be warned, this script can make huge damage if u dont know how to use it.

To be hornest I would never use some like this, instead would execute kill manually..

Upvotes: -1

Related Questions