Add PSQL_WATCH_PAGER for psql's \watch command.
authorThomas Munro <tmunro@postgresql.org>
Mon, 12 Jul 2021 23:13:48 +0000 (11:13 +1200)
committerThomas Munro <tmunro@postgresql.org>
Mon, 12 Jul 2021 23:43:21 +0000 (11:43 +1200)
commit7c09d2797ecdf779e5dc3289497be85675f3d134
tree4b223d030bc675e57ae1afde13b0a9217a17e136
parentf014b1b9bb8eda4e82c1805969dbae2b07b7d54d
Add PSQL_WATCH_PAGER for psql's \watch command.

Allow a pager to be used by the \watch command.  This works but isn't
very useful with traditional pagers like "less", so use a different
environment variable.  The popular open source tool "pspg" (also by
Pavel) knows how to display the output if you set PSQL_WATCH_PAGER="pspg
--stream".

To make \watch react quickly when the user quits the pager or presses
^C, and also to increase the accuracy of its timing and decrease the
rate of useless context switches, change the main loop of the \watch
command to use sigwait() rather than a sleeping/polling loop, on Unix.

Supported on Unix only for now (like pspg).

Author: Pavel Stehule <pavel.stehule@gmail.com>
Author: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/CAFj8pRBfzUUPz-3gN5oAzto9SDuRSq-TQPfXU_P6h0L7hO%2BEhg%40mail.gmail.com
doc/src/sgml/ref/psql-ref.sgml
src/bin/psql/command.c
src/bin/psql/common.c
src/bin/psql/common.h
src/bin/psql/help.c
src/bin/psql/startup.c