How to sandbox (or monitor) a process on OSX

mac-osxmonitoringprocess

I'm running a piece of OCR software [with gui, etc] on OSX that watches a folder and OCRs PDFs that are put in there. Occasionally the process starts behaving poorly and consumes a huge amount of system memory and CPU, running indefinitely on a particular PDF.

  • I'd like to know how to monitor that process to kill it under such circumstances.
  • I'd also like to prevent it from bringing the system to a halt, e.g. by sandboxing somehow.

Best Answer

You can sandbox an application on OS X with the built in sandbox(7) facility. See the man pages for sandbox(7), sandbox-exec(1) and sandboxd(8). This repository of sandbox scripts may also be useful.

OS X 10.7 (Lion) will bring more application sandboxing features, as well, but the details on Apple's site are light. I would assume it will be related to the above feature.