fix another subtle state race
pilot.{stdout,stderr,logfile} are not available.

also added some more state transition safeties

;
merge from devel
Merge branch 'devel' into feature/pilot_error
resolve conflicts after merge from devel
resolve conflicts from merge from devel
resolve conflicts from merge from devel
Merge branch 'devel' into feature/pilot_error