Assign PTY to stdout and stderr and write PTY output to tmp_file
Restart job if died - it can occur when worker host reboots due to crash.