Fix attach failure path

This closes #444.

A mutex in the attach failure path was not getting unlocked, so the connection would hang forever instead of returning an error. In the process of writing a test case for this, I did a bit of cleanup, and fixed the exec package when no streams are used.