Fixed a race condition.
Removed a comment made obsolete by the previous commit.
Restored stdin redirection.
Merge pull request #1176 from abalkin/issue-1175

Fixed a race condition.