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 63514e342ebcca2761b3f6a6c38ddcbdc7d8b6c8..cc8cd1140c70d7e6a88d4426797380630d5624f2 100644 (file)
@@ -2220,6 +2220,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