1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-02-01 13:27:47 +02:00

SIGINT for password promt

This commit is contained in:
Grigory Smolkin 2017-11-01 08:21:19 +03:00
parent 4c63a7e3e5
commit 80244158cd

View File

@ -58,6 +58,7 @@ static void on_interrupt(void);
static void on_cleanup(void); static void on_cleanup(void);
static void exit_or_abort(int exitcode); static void exit_or_abort(int exitcode);
static const char *get_username(void); static const char *get_username(void);
static pqsigfunc oldhandler = NULL;
/* /*
* Unit conversion tables. * Unit conversion tables.
@ -1079,6 +1080,7 @@ parse_pair(const char buffer[], char key[], char value[])
static void static void
prompt_for_password(const char *username) prompt_for_password(const char *username)
{ {
pqsignal(SIGINT, oldhandler);
if (password) if (password)
{ {
free(password); free(password);
@ -1105,6 +1107,7 @@ prompt_for_password(const char *username)
password = simple_prompt(message, 100, false); password = simple_prompt(message, 100, false);
} }
#endif #endif
init_cancel_handler();
} }
PGconn * PGconn *
@ -1820,7 +1823,7 @@ handle_sigint(SIGNAL_ARGS)
static void static void
init_cancel_handler(void) init_cancel_handler(void)
{ {
pqsignal(SIGINT, handle_sigint); oldhandler = pqsignal(SIGINT, handle_sigint);
} }
#else /* WIN32 */ #else /* WIN32 */