change pthread_cond_wait to pthread_cond_timedwait to allow CTRL-C