1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-12 02:37:31 +03:00

Ensure that 'errno' is saved and restored by all signal handlers that

might change it.  Experimentation shows that the signal handler call
mechanism does not save/restore errno for you, at least not on Linux
or HPUX, so this is definitely a real risk.
This commit is contained in:
Tom Lane
2000-12-18 17:33:42 +00:00
parent c431db9714
commit 5491233f52
6 changed files with 79 additions and 16 deletions

View File

@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.28 2000/12/15 17:54:43 petere Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.29 2000/12/18 17:33:42 tgl Exp $
*/
#include "postgres.h"
#include "common.h"
@@ -258,6 +258,8 @@ volatile bool cancel_pressed;
void
handle_sigint(SIGNAL_ARGS)
{
int save_errno = errno;
/* Don't muck around if copying in or prompting for a password. */
if ((copy_in_state && pset.cur_cmd_interactive) || prompt_state)
return;
@@ -274,6 +276,7 @@ handle_sigint(SIGNAL_ARGS)
write_stderr("Could not send cancel request: ");
write_stderr(PQerrorMessage(cancelConn));
}
errno = save_errno; /* just in case the write changed it */
}
#endif /* not WIN32 */