Unix Programming - ncurses getch SIGWINCH

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2005 > ncurses getch SIGWINCH





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author ncurses getch SIGWINCH
Average Joe

2005-01-27, 2:51 am

My program sits in a blocking ncurses getch() call. When I receive the
signal SIGWINCH (screen resize), how do I inject a character into the
stdin so that getch will wake up?

I know I can use a non-blocking getch() call but it rails the CPU, and
sleeping is inefficient.

--
Average Joe
DINH Viet Hoa

2005-01-27, 7:54 am

Average Joe wrote :

> My program sits in a blocking ncurses getch() call. When I receive the
> signal SIGWINCH (screen resize), how do I inject a character into the
> stdin so that getch will wake up?
>
> I know I can use a non-blocking getch() call but it rails the CPU, and
> sleeping is inefficient.


use select() with a timeout of 0.1 sec (sufficient most of time for
user interface) before getch()

--
DINH V. Hoa,

"Paraît-il que c'est ce que recherchent la majorité des djeunz. Il n'y a plus
aucun attrait pour les métiers scientifiques ni techniques. Ils veulent être
chanteur, acteur ou fonctionnaire. C'est désépérant..." -- Emmanuel Delahaye

alexs

2005-01-27, 7:54 am

Ncurses will (or perhaps it has to be enabled) return KEY_RESIZE from
getch() so you can handle it that way.

Thomas Dickey

2005-01-28, 8:47 pm

alexs <spam@alexs.org> wrote:
> Ncurses will (or perhaps it has to be enabled) return KEY_RESIZE from
> getch() so you can handle it that way.


yes - the SIGWINCH handler is normally compiled-in.
But it may be overridden by defining another handler.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Average Joe

2005-01-29, 5:54 pm

Thomas Dickey wrote:
> alexs <spam@alexs.org> wrote:
>
>
>
> yes - the SIGWINCH handler is normally compiled-in. But it may be
> overridden by defining another handler.


Even with halfdelay(1) set, it appears KEY_RESIZE isn't returned from
getch() when the screen is resizing until after a doupdate() is issued.

Can anyone verify this?

This means I always have to issue a doupdate() when getch() returns ERR,
just to catch the resize "in the act."

Is this intended behavior?

--
Average Joe
Average Joe

2005-01-29, 5:54 pm

> This means I always have to issue a doupdate() when getch() returns
> ERR, just to catch the resize "in the act."


I am using Linux FC3. Does this happen to anyone else?

When resizing during a getch(), getch() returns ERR with errno == EINTR.
After this, the next call to getch() will return KEY_RESIZE only if a
doupdate() has been issued.

This seems to be broken behavior. Is this the intended behavior?

--
Average Joe

Thomas Dickey

2005-01-31, 8:51 pm

Average Joe <joe@use.net> wrote:
> Even with halfdelay(1) set, it appears KEY_RESIZE isn't returned from
> getch() when the screen is resizing until after a doupdate() is issued.


> Can anyone verify this?


I've run into that before, but not for quite a while (and don't recall
exactly what the problem was that produces this symptom).

> Is this intended behavior?


no

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Thomas Dickey

2005-01-31, 8:51 pm

Average Joe <joe@use.net> wrote:
[vbcol=seagreen]
> I am using Linux FC3. Does this happen to anyone else?


> When resizing during a getch(), getch() returns ERR with errno == EINTR.
> After this, the next call to getch() will return KEY_RESIZE only if a
> doupdate() has been issued.


> This seems to be broken behavior. Is this the intended behavior?


no (but you could post a short test program so we could see exactly the
same result).

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com