diff options
| author | Tom Lane | 2000-12-18 17:33:42 +0000 |
|---|---|---|
| committer | Tom Lane | 2000-12-18 17:33:42 +0000 |
| commit | 5491233f5245c464be2286ad894448b21ef757db (patch) | |
| tree | 8badaae022de82ec4cd53ffe42e2c22e681c394d /src/bin/psql/common.c | |
| parent | c431db9714bfca24f05fd301ae2f027f83689e4f (diff) | |
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.
Diffstat (limited to 'src/bin/psql/common.c')
| -rw-r--r-- | src/bin/psql/common.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index cc57771b70e..ccbbb6c1443 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -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 */ |
