handle ^D and ^C while password prompting

This commit is contained in:
Jethro Grassie 2018-02-01 15:32:30 -05:00
parent ed67e5c001
commit a4b50a6f51
No known key found for this signature in database
GPG key ID: DE8ED755616565BB
4 changed files with 24 additions and 6 deletions

View file

@ -153,8 +153,12 @@ namespace tools
}
return r;
#else
static struct sigaction sa;
memset(&sa, 0, sizeof(struct sigaction));
sa.sa_handler = posix_handler;
sa.sa_flags = 0;
/* Only blocks SIGINT, SIGTERM and SIGPIPE */
signal(SIGINT, posix_handler);
sigaction(SIGINT, &sa, NULL);
signal(SIGTERM, posix_handler);
signal(SIGPIPE, SIG_IGN);
m_handler = t;