Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita062473

Browse files
committed
Fix problems with coredumps due to ^C when longjmp buffer isn't valid.
Now, we will only catch ^C at times when it is valid.
1 parentb32cac8 commita062473

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

‎src/bin/psql/mainloop.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.37 2001/03/22 04:00:21 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.38 2001/03/2300:36:38 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"mainloop.h"
@@ -137,6 +137,10 @@ MainLoop(FILE *source)
137137
break;
138138
}
139139
}
140+
141+
/* establish the control-C handler only after main_loop_jmp is ready */
142+
pqsignal(SIGINT,handle_sigint);/* control-C => cancel */
143+
140144
#endif/* not WIN32 */
141145

142146
if (slashCmdStatus==CMD_NEWEDIT)
@@ -546,7 +550,8 @@ MainLoop(FILE *source)
546550
/*
547551
* Process query at the end of file without a semicolon
548552
*/
549-
if (query_buf->len>0&& !pset.cur_cmd_interactive)
553+
if (query_buf->len>0&& !pset.cur_cmd_interactive&&
554+
successResult==EXIT_SUCCESS)
550555
{
551556
success=SendQuery(query_buf->data);
552557

@@ -556,6 +561,14 @@ MainLoop(FILE *source)
556561
successResult=EXIT_BADCONN;
557562
}
558563

564+
/*
565+
* Reset SIGINT handler because main_loop_jmp will be invalid as soon
566+
* as we exit this routine. If there is an outer MainLoop instance,
567+
* it will re-enable ^C catching as soon as it gets back to the top
568+
* of its loop and resets main_loop_jmp to point to itself.
569+
*/
570+
pqsignal(SIGINT,SIG_DFL);
571+
559572
destroyPQExpBuffer(query_buf);
560573
destroyPQExpBuffer(previous_buf);
561574

‎src/bin/psql/startup.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.45 2001/03/22 04:00:23 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.46 2001/03/2300:36:38 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99

@@ -223,10 +223,6 @@ main(int argc, char *argv[])
223223
SetVariable(pset.vars,"PORT",PQport(pset.db));
224224
SetVariable(pset.vars,"ENCODING",pg_encoding_to_char(pset.encoding));
225225

226-
#ifndefWIN32
227-
pqsignal(SIGINT,handle_sigint);/* control-C => cancel */
228-
#endif
229-
230226
/*
231227
* Now find something to do
232228
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp