Fixes recursive lock acquisition bug encountered on linux.

Fixes an issue where SNAP recursively acquires a lock when reading from standard in on Linux.