oink
April 20, 2007, 11:52am
1
I’m using ncurses library with qnx core 6.3.2
and I want to catch SIGWINCH signal
(“window change”; if terminal is resized).
My code:
signal( SIGWINCH, my_handler ); // install my_handler
…
signal( SIGWINCH, SIG_DFL ); // restore default action
void my_handler( int sig_number ) // sig. handler
{
int nh, nw;
getmaxyx(stdscr, nh, nw);
}
My program works well,
but when SIGWINCH signal arrives
program gets killed ! (it is immediately terminated)
Why?
mario
April 20, 2007, 11:57am
2
Why do you call signal() a second time with SIG_DFL? You should not, it cancels the effect of the first signal().
Make sure any function you call int the signal handler is signal safe.
oink
April 20, 2007, 12:27pm
3
I know that - Don’t treat me like c/c++ kid .
I install my handler & than wait (in loop) for signal to come.
But when the signal arrives - my program is ‘brutally’ terminated !
/and I don’t know why ?..
mario
April 20, 2007, 1:55pm
4
I have no way to know what you know…
Please define “brutally” terminated, do you get a core dump? What happen if you do nothing inside the handler.
oink
April 20, 2007, 2:32pm
5
no, there is no message - it is like normal, clean exit, but it isn’t normal;
with empty handler is the same
signal( SIGWINCH, my_handler ); // install my_handler
void my_handler( int sig_number ) // sig. handler
{
}
mario
April 20, 2007, 2:52pm
6
What do you mean by normal, clean exit?
Is it possible you are getting a different signal then SIGWINCH, that you aren’t handling (i’m not familliar with ncurse)
What if you ignore the signal (SIG_IGN) instead.
What if the function that is being interrupted return -1 with errno = EINTR and that it’s not being handled properly.
seanb
April 20, 2007, 6:05pm
7
Run it in gdb and you’ll see the signals that are
hitting it.
-seanb