From 311bc147ff0924b651f36910925a163c4f3b4a6c Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 7 Dec 2016 12:39:24 -0500 Subject: [PATCH] Restore psql's SIGPIPE setting if popen() fails. Ancient oversight in PageOutput(): if popen() fails, we'd better reset the SIGPIPE handler before returning stdout, because ClosePager() won't. Noticed while fixing the empty-PAGER issue. --- src/bin/psql/print.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c index bf5f4ff5671..8809cfa8b85 100644 --- a/src/bin/psql/print.c +++ b/src/bin/psql/print.c @@ -2087,6 +2087,10 @@ PageOutput(int lines, unsigned short int pager) pagerpipe = popen(pagerprog, "w"); if (pagerpipe) return pagerpipe; + /* if popen fails, silently proceed without pager */ +#ifndef WIN32 + pqsignal(SIGPIPE, SIG_DFL); +#endif #ifdef TIOCGWINSZ } #endif