Home > front end >  Signal in wgetnstr function
Signal in wgetnstr function

Time:06-16

I have wgetnstr(input, str, MSG_SIZE) and when I write something and press C-c it literally prints ^C, instead of singal. I even handled this signal explicitly with signal(SIGINT, handler) but nothing seems to work. Is it even possible to handle signals inside of ncurses' functions?

CodePudding user response:

There's no MCVE given, but echoing controls like that would happen if one used cbreak or raw. The default behavior in ncurses (any curses implementation) lets SIGINT kill the application.

There's a summary of signal behavior for ncurses in the initscr manual page. Likewise, wgetnstr manual page documents the control characters which it respects. The description there gives a hint that writing your own variation would be not difficult:

The function getstr is equivalent to a series of calls to getch, until a newline or carriage return is received (the terminating character is not included in the returned string). The resulting value is placed in the area pointed to by the character pointer str, followed by a NUL.

  • Related