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 f45ce677d08c12ac97e9ea42e572c4f00a8b2aec..a1d2e9709d1f39a343c44e6e2528706cbf3c24da 100644 (file)
@@ -2880,6 +2880,8 @@ PageOutput(int lines, const printTableOpt *topt)
            pagerpipe = popen(pagerprog, "w");
            if (pagerpipe)
                return pagerpipe;
+           /* if popen fails, silently proceed without pager */
+           restore_sigpipe_trap();
        }
    }