=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cdio/cdio.c,v retrieving revision 1.80 retrieving revision 1.81 diff -c -r1.80 -r1.81 *** src/usr.bin/cdio/cdio.c 2021/01/18 00:44:00 1.80 --- src/usr.bin/cdio/cdio.c 2021/08/13 10:56:54 1.81 *************** *** 1,4 **** ! /* $OpenBSD: cdio.c,v 1.80 2021/01/18 00:44:00 mortimer Exp $ */ /* Copyright (c) 1995 Serge V. Vakulenko * All rights reserved. --- 1,4 ---- ! /* $OpenBSD: cdio.c,v 1.81 2021/08/13 10:56:54 schwarze Exp $ */ /* Copyright (c) 1995 Serge V. Vakulenko * All rights reserved. *************** *** 63,68 **** --- 63,69 ---- #include #include #include + #include #include #include #include *************** *** 158,163 **** --- 159,165 ---- int msf = 1; const char *cddb_host; char **track_names; + volatile sig_atomic_t signo; EditLine *el = NULL; /* line-editing structure */ History *hist = NULL; /* line-editing history */ *************** *** 179,184 **** --- 181,187 ---- int play_next(char *arg); int play_prev(char *arg); int play_same(char *arg); + void sigint_handler(int); char *input(int *); char *prompt(void); void prtrack(struct cd_toc_entry *e, int lastflag, char *name); *************** *** 1499,1516 **** return s.data->header.audio_status; } char * input(int *cmd) { char *buf; int siz = 0; char *p; HistEvent hev; do { ! if ((buf = (char *) el_gets(el, &siz)) == NULL || !siz) { ! *cmd = CMD_QUIT; fprintf(stderr, "\r\n"); return (0); } if (strlen(buf) > 1) --- 1502,1537 ---- return s.data->header.audio_status; } + void + sigint_handler(int signo_arg) + { + signo = signo_arg; + } + char * input(int *cmd) { + struct sigaction sa; char *buf; int siz = 0; char *p; HistEvent hev; + memset(&sa, 0, sizeof(sa)); do { ! signo = 0; ! sa.sa_handler = sigint_handler; ! if (sigaction(SIGINT, &sa, NULL) == -1) ! err(1, "sigaction"); ! buf = (char *)el_gets(el, &siz); ! sa.sa_handler = SIG_DFL; ! if (sigaction(SIGINT, &sa, NULL) == -1) ! err(1, "sigaction"); ! if (buf == NULL || siz <= 0) { fprintf(stderr, "\r\n"); + if (siz < 0 && errno == EINTR && signo == SIGINT) + continue; + *cmd = CMD_QUIT; return (0); } if (strlen(buf) > 1)