Replace the usleep() hack in output.cc with proper thread signaling.