Return process exit code for attach

Fixes #2240