Skip navigation

For the way I use PhantomJS, it has a habit of hanging and leaving me with a bunch of zombie phantomjs.exe processes. My solution was to put together a timer that would periodically kill all phantomjs.exe processes (and all their descendants) which were older than a specified number of minutes. It’s mildly elegant, but also mildly brutish, and much more overhead than I wanted.

I can’t believe this didn’t occur to me sooner. The easier, cleaner way is to add the following to the script you’re having it run:

Now all my phantomjs.exe instances reliably off themselves once the timer elapses.