Improve signal handling and leaving/entering curses.

git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@570 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
Pasi Kallinen 2010-05-16 17:06:05 +00:00
parent 725b6cd1d2
commit d623b5c0d6
2 changed files with 14 additions and 0 deletions

View File

@ -1973,6 +1973,8 @@ editoptions (int game)
myargv[1] = dgl_format_str(game, me, myconfig[game]->rc_fmt, NULL); myargv[1] = dgl_format_str(game, me, myconfig[game]->rc_fmt, NULL);
myargv[2] = 0; myargv[2] = 0;
clear();
refresh();
endwin (); endwin ();
editor = fork(); editor = fork();
@ -1985,12 +1987,15 @@ editoptions (int game)
} }
else if (editor == 0) else if (editor == 0)
{ {
signals_block();
editor_main (2, myargv); editor_main (2, myargv);
signals_release();
exit(0); exit(0);
} }
else else
waitpid(editor, NULL, 0); waitpid(editor, NULL, 0);
initcurses();
refresh (); refresh ();
check_retard(1); check_retard(1);
} }

View File

@ -263,6 +263,8 @@ dgl_exec_cmdqueue(struct dg_cmdpart *queue, int game, struct dg_user *me)
myargv[1] = p2; myargv[1] = p2;
myargv[2] = 0; myargv[2] = 0;
clear();
refresh();
endwin(); endwin();
idle_alarm_set_enabled(0); idle_alarm_set_enabled(0);
child = fork(); child = fork();
@ -271,11 +273,14 @@ dgl_exec_cmdqueue(struct dg_cmdpart *queue, int game, struct dg_user *me)
debug_write("exec-command fork failed"); debug_write("exec-command fork failed");
graceful_exit(114); graceful_exit(114);
} else if (child == 0) { } else if (child == 0) {
signals_block();
execvp(p1, myargv); execvp(p1, myargv);
signals_release();
exit(0); exit(0);
} else } else
waitpid(child, NULL, 0); waitpid(child, NULL, 0);
idle_alarm_set_enabled(1); idle_alarm_set_enabled(1);
initcurses();
refresh(); refresh();
check_retard(1); check_retard(1);
} }
@ -338,6 +343,8 @@ dgl_exec_cmdqueue(struct dg_cmdpart *queue, int game, struct dg_user *me)
setproctitle("%s [playing %s]", me->username, myconfig[userchoice]->shortname); setproctitle("%s [playing %s]", me->username, myconfig[userchoice]->shortname);
clear();
refresh();
endwin (); endwin ();
signal(SIGWINCH, SIG_DFL); signal(SIGWINCH, SIG_DFL);
@ -353,6 +360,7 @@ dgl_exec_cmdqueue(struct dg_cmdpart *queue, int game, struct dg_user *me)
myconfig[userchoice]->bin_args[i] = tmpstr; myconfig[userchoice]->bin_args[i] = tmpstr;
} }
signals_block();
idle_alarm_set_enabled(0); idle_alarm_set_enabled(0);
/* launch program */ /* launch program */
ttyrec_main (userchoice, me->username, ttyrec_main (userchoice, me->username,
@ -362,6 +370,7 @@ dgl_exec_cmdqueue(struct dg_cmdpart *queue, int game, struct dg_user *me)
/* lastly, run the generic "do these when a game is left" commands */ /* lastly, run the generic "do these when a game is left" commands */
dgl_exec_cmdqueue(globalconfig.cmdqueue[DGLTIME_GAMEEND], userchoice, me); dgl_exec_cmdqueue(globalconfig.cmdqueue[DGLTIME_GAMEEND], userchoice, me);
idle_alarm_set_enabled(1); idle_alarm_set_enabled(1);
signals_release();
setproctitle ("%s", me->username); setproctitle ("%s", me->username);
initcurses (); initcurses ();