Return process exit code for attach

Fixes #2240
Merge pull request #2926 from crosbymichael/attach-wait

Return process exit code for attach