Implement timeout when waiting.
Fix TUNDEV environment handling.