Question: Preview app crash and PID weirdness
MacBook Pro (Retina, 13-inch, Early 2015)
Processor: 2.7 GHz Intel Core i5
Memory: 8 GB 1867 MHz DDR3
macOS: Sierra (10.12.6)
This started because the PreviewApp would randomly hang. It just becomes unresponsive. I try to force quit it, but that is ineffective. I use the Activity Monitor to try and locate Preview process, but it is not in the list. It also does not appear when I ps, pgrep, or top from the terminal. The problem is rare, but when it happens I have no recourse but to ungracefully shut down my mac and force a reboot. A graceful reboot is not possible because Preview can't be stopped by the OS either.
I was wondering if the process might still be alive, but orphaned in some way and not accessible to the process monitor. I thought if I knew the PID then maybe I could kill it from the command line. So I made this AppleScript that I run in the background and it periodically checks for the Preview PID. I made it so that it reports the Preview PID in the notifications any time the PID changes.
I was expecting the PID to only change when I quit Preview and then restarted it later. What I find instead is that Preview changes PID quite often, without quitting and restarting the app.
Q: Is this normal for Preview or Mac apps, in general?
I use linux on a daily basis and I have never seen this kind of behavior in linux.
Incidentally, in case you are wondering, yes I'm sure I'm capturing the Preview PID and not the grep PID.
Also, when Preview hangs and I do have the last recorded PID, trying to kill it results in a "No such process" error.
So, I'm starting to suspect that the hanging and the process changes might be related.
MacBook Pro with Retina display, macOS Sierra (10.12.6)