Only loop on the stdin when it's a terminal

This keeps it easy to use when debugging but means the service
shouldn't end up eating the CPU as it tries to read EOF ever other
instruction cycle.

Change-Id: I34ad25ea1a26db78541b4aebad4cb5c1fd4d97a0