Mercurial > ~astiob > upreckon > hgweb
diff upreckon/_unixmodule.cpp @ 218:65b5c9390010
With _unix, Escape presses now cancel test data unarchiving
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Mon, 22 Aug 2011 22:34:09 +0300 |
parents | 8c4e92fb32d8 |
children | d06e57b182a9 |
line wrap: on
line diff
--- a/upreckon/_unixmodule.cpp Sun Aug 21 01:24:29 2011 +0300 +++ b/upreckon/_unixmodule.cpp Mon Aug 22 22:34:09 2011 +0300 @@ -2,7 +2,6 @@ #include <Python.h> #include <structmember.h> -#include <stdio.h> #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> @@ -155,6 +154,9 @@ #ifdef HAVE_TERMIOS_H static bool catch_escape = false; static struct termios orig_termios; +#ifdef O_ASYNC +static int orig_stdout_fl; +#endif #endif typedef struct @@ -405,6 +407,10 @@ #endif #endif +#if defined HAVE_TERMIOS_H && defined O_ASYNC + signal(SIGIO, SIG_DFL); +#endif + if (c2ppipe[1] < 3) { int newfd; @@ -1275,6 +1281,9 @@ #ifdef HAVE_TERMIOS_H if (catch_escape) { +#ifdef O_ASYNC + signal(SIGIO, SIG_DFL); +#endif char c; while (read(0, &c, 1) == -1 && errno == EINTR) { @@ -1309,6 +1318,9 @@ static void restore_termios(void) { tcsetattr(0, TCSAFLUSH, &orig_termios); +#ifdef O_ASYNC + fcntl(0, F_SETFL, orig_stdout_fl); +#endif #ifdef USE_WAKEUP_FD close_intpipe(); #endif @@ -1443,6 +1455,10 @@ if (!Py_AtExit(restore_termios) && !tcsetattr(0, TCSAFLUSH, &new_termios)) { catch_escape = true; +#ifdef O_ASYNC + orig_stdout_fl = fcntl(0, F_GETFL); + fcntl(0, F_SETFL, orig_stdout_fl | O_ASYNC); +#endif } } #ifdef USE_WAKEUP_FD