Curses signal handling question
laman at sdcsvax.UUCP
laman at sdcsvax.UUCP
Wed Apr 18 00:27:12 AEST 1984
Execute the following program... See if you can still generate the problem.
The only "problem" I had was that I had to type a line feed to get wgetstr()
to return; otherwise it kept reading and the alarm went off. If you still
have the missing alarm problem, then let me know (And the net too... someone
else may have encoutered this bug). If this works then I would suggest going
over your program. I tried to change as little as possible of the code you
sent.
Program begins:...
#include <curses.h>
#include <signal.h>
#define NUMSEC 10
WINDOW *window;
main() {
register i;
int hangup();
char line[80];
initscr();
window = stdscr;
mvaddstr(3, 5, "Here we go...\n");
refresh();
/* Original code from the net */
signal(SIGALRM,hangup); /* If the alarm sounds, log user off */
alarm(NUMSEC); /* Call the alarm clock */
/* I added the return value check and the following line for debuging */
i = wgetstr( window, line ); /* Get a line from the screen */
fprintf(stderr, "wgetstr returned %d.\n", i); fflush(stderr); /* Mike Added */
signal(SIGALRM,SIG_IGN); /* If we returned from input routine, ignore
alarm */
/* End of original code from network */
mvaddstr(5, 5, "No problem...\n");
refresh();
goodbye(0);
}
hangup() {
write(2, "HANGUP\n", 7);
goodbye(1);
}
goodbye(retval)
int retval;
{
endwin();
exit(retval);
}
End of program...
Mike Laman
UUCP: {ucbvax,philabs,sdccsu3,sdcsla}!sdcsvax!laman
More information about the Comp.unix.wizards
mailing list