Restore psql's SIGPIPE setting if popen() fails.
authorTom Lane
Wed, 7 Dec 2016 17:39:24 +0000 (12:39 -0500)
committerTom Lane
Wed, 7 Dec 2016 17:39:24 +0000 (12:39 -0500)
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

index 85ac76b8fe3f412e705e14e633b15dbaa2f20575..b48fb8dd7ff23f6811374785a960ebde0696c6e0 100644 (file)
@@ -2217,6 +2217,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