MacOS – Preview accessing closed files (El Cap 10.11.3)

macospreviewquicklook

on El Cap (I noticed this since upgrade to 10.11.3) Preview keeps accessing closed PDF files, which means I cannot empty the trash. In fact the problem exists even if Preview is not running. I open a file, close Preview and the file, trash it, try to empty the trash and I get 'the file is in use'. Just now:

:~$ lsof .Trash/tutorial-strata.pdf
COMMAND     PID      USER   FD   TYPE DEVICE SIZE/OFF      NODE NAME
Preview   62216 me  txt    REG    1,4   196236 109606954 .Trash/tutorial-strata.pdf
QuickLook 71216 me  txt    REG    1,4   196236 109606954 .Trash/tutorial-strata.pdf

(as you might notice Quicklook wanted some of the action despite the fact I did not activate a preview of the file). How can I stop this most annoying behaviour?

#

following GhostLyrics' suggestion I run:

:~$ ps -ef|grep Prev
  501  2411     1   0 12:00am ??         0:08.49 /Applications/Preview.app/Contents/MacOS/Preview -psn_0_28633933
  501  2412     1   0 12:00am ??         0:00.01 /Applications/Preview.app/Contents/XPCServices/com.apple.Preview.TrustedBookmarksService.xpc/Contents/MacOS/com.apple.Preview.TrustedBookmarksService
  501 16880 57035   0 12:36pm ttys000    0:00.00 grep Prev

so Preview is still running in the background despite the fact it is not open (according to the Dock):

The Dock showing Preview should not be running

Hence it looks like that preview is not actually closing properly for some reason or another….

Best Answer

I do not have a solution, but I can confirm that this definitely happens (10.11.3) and appears to be a regression. (I see reports of this from 2011, but it has never bitten me all these years, until fairly recently.) The OP is not hallucinating and his report is entirely accurate, and he is not confused about what he did.

Interestingly, I never had the file open in Preview. I was not running Preview! The file was created by Print-to-PDF from Safari onto my Desktop. The only thing I did with it there was to decide I didn't actually want that file, and cmd-Del it to the Trash. Then when I went to empty the trash I got the "in use" error dialog.

I have been having this same problem for just the last few months. I used lsof and the Activity Monitor to see what was going on. (It was a QuickLook satellite process.)

My random theory is that QuickLook is aggressively caching the content of new files, so that they can come up super-fast, should I happen to want it. Then a bug happens and it forgets to free that (handle leak). Or something like that. The file stays "in use" until I log out or kill the offending process.

Maybe Apple will fix this bug. Until then: Yeah, it's a for-real problem.