Re: proposal - psql - use pager for \watch command - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: proposal - psql - use pager for \watch command
Date
Msg-id CA+hUKGLsd9afMbDog8Bc6xfuTu8w0qJV06mtJmDDPZ7uw8=RbA@mail.gmail.com
Whole thread Raw
In response to Re: proposal - psql - use pager for \watch command  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: proposal - psql - use pager for \watch command
Re: proposal - psql - use pager for \watch command
List pgsql-hackers
On Mon, Mar 22, 2021 at 5:10 PM Pavel Stehule <pavel.stehule@gmail.com> wrote:
> probably there will not be an issue inside ncurses - the most complex part of get_event is polling of input sources -
ttyand some other. The pspg should not to stop there on tty reading.
 

The problem is that Apple's /dev/tty device is defective, and doesn't
work in poll().  It always returns immediately with revents=POLLNVAL,
but pspg assumes that data is ready and tries to read the keyboard and
then blocks until I press a key.  This seems to fix it:

+#ifndef __APPLE__
+               /* macOS can't use poll() on /dev/tty */
                state.tty = fopen("/dev/tty", "r+");
+#endif
                if (!state.tty)
                        state.tty = fopen(ttyname(fileno(stdout)), "r");

A minor problem is that on macOS, _GNU_SOURCE doesn't seem to imply
NCURSES_WIDECHAR, so I suspect Unicode will be broken unless you
manually add -DNCURSES_WIDECHAR=1, though I didn't check.



pgsql-hackers by date:

Previous
From: ikedamsh
Date:
Subject: Re: About to add WAL write/fsync statistics to pg_stat_wal view
Next
From: Sean Jezewski
Date:
Subject: Re: PG13 fails to startup even though the current transaction is equal to the target transaction