For issue #9. @paoloantinori reports that it is not enough to wait for the pid.  Thanks to @waterlink for the solution.