I am writing a program to display a database to the screen(xterm) and want to allow the window resize signal to increase/decrease the amount data that is displayed. I have a signal handler function for catching the SIGWINCH event and calling a function to reallocate the space for the windows (stdscr and curscr) an reallocate the space for the windows.
The resize function looks something like:
//GLOBAL CONSTANTS, initialized elsewhere to the correct values
WINDOW* display;
int maxX;
int maxY;
// resize event function
void resizeHandler() {
WINDOW*curscrOld = curscr;
WINDOW*stdscrOld = stdscr;
delwin(curscrOld);
delwin(stdscrOld);
endwin();
display = initscr();
getmaxyx(display, maxY, maxX);
signal(SIGWINCH, resizeHandler);
}
The problem with the reallocation function seems to be that I put in another call to initscr(). Not every time, but frequently enough to be annoying, the program will have a segmentation fault during the call to initscr() when a resize event occurs. The reason I put in another call to initscr() was getmaxyx() was not updating the size of the windows on a resize event, I tried to just use the endwin() then a call to refresh() to reinitialize the values with no luck. Is there someplace else I can get the xterm's window size and the use some calls to newwin() to create new stdscr and curscr variables on my own? I am running on Solaris 8, thanks in advance for any help.