/* * With readline 7.0, this aborts after one second due to SIGALRM. */ #include #include #include #include /* Dedicated thread to catch SIGALRM */ void *sigwait_thread (void *arg) { sigset_t *sigset = arg; int sig; for (;;) sigwait(sigset, &sig); } int main() { /* Block SIGALRM */ sigset_t sigset; sigemptyset(&sigset); sigaddset(&sigset, SIGALRM); pthread_sigmask(SIG_BLOCK, &sigset, NULL); /* Create and detach sigwait thread */ pthread_t sigwait_tid; pthread_create(&sigwait_tid, NULL, sigwait_thread, &sigset); pthread_detach(sigwait_tid); /* Set up a 1-second recurring timer */ struct itimerval itv = {{1, 0}, {1, 0}}; setitimer(ITIMER_REAL, &itv, NULL); //rl_catch_signals = 0; /* This would have no effect anyway */ while (readline("> ")); return 0; }