Modified the run to put PID first and catch any errrors to write failed pid.  Doesn't seem to work though.