Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8024415

Browse files
committed
SIGINT for password promt
1 parent 4c63a7e commit 8024415

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/utils/pgut.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ static void on_interrupt(void);
5858
static void on_cleanup(void);
5959
static void exit_or_abort(int exitcode);
6060
static const char *get_username(void);
61+
static pqsigfunc oldhandler = NULL;
6162

6263
/*
6364
* Unit conversion tables.
@@ -1079,6 +1080,7 @@ parse_pair(const char buffer[], char key[], char value[])
10791080
static void
10801081
prompt_for_password(const char *username)
10811082
{
1083+
pqsignal(SIGINT, oldhandler);
10821084
if (password)
10831085
{
10841086
free(password);
@@ -1105,6 +1107,7 @@ prompt_for_password(const char *username)
11051107
password = simple_prompt(message, 100, false);
11061108
}
11071109
#endif
1110+
init_cancel_handler();
11081111
}
11091112

11101113
PGconn *
@@ -1820,7 +1823,7 @@ handle_sigint(SIGNAL_ARGS)
18201823
static void
18211824
init_cancel_handler(void)
18221825
{
1823-
pqsignal(SIGINT, handle_sigint);
1826+
oldhandler = pqsignal(SIGINT, handle_sigint);
18241827
}
18251828
#else /* WIN32 */
18261829

0 commit comments

Comments
 (0)