diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2012-07-04 21:23:48 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2012-07-04 21:23:48 +1000 |
commit | d84f0f823eeeecdf0498aadd3fbb1d11dabc0837 (patch) | |
tree | 2c33f922107a28f3ea10b565d54599f3f2d45d93 /os | |
parent | 12bfb4cf1bebb66d2c2eb76b93c18a2915b865e5 (diff) | |
parent | d04dfe3f754ad3a5f158057175cbd44319c1ae51 (diff) |
Merge branch 'sigio-vt-switch-issues' into for-keith
Conflicts:
test/Makefile.am
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'os')
-rw-r--r-- | os/utils.c | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/os/utils.c b/os/utils.c index 998c3ed4a..253793467 100644 --- a/os/utils.c +++ b/os/utils.c @@ -1167,15 +1167,15 @@ OsBlockSignals(void) if (BlockedSignalCount++ == 0) { sigset_t set; +#ifdef SIGIO + OsBlockSIGIO(); +#endif sigemptyset(&set); sigaddset(&set, SIGALRM); sigaddset(&set, SIGVTALRM); #ifdef SIGWINCH sigaddset(&set, SIGWINCH); #endif -#ifdef SIGIO - sigaddset(&set, SIGIO); -#endif sigaddset(&set, SIGTSTP); sigaddset(&set, SIGTTIN); sigaddset(&set, SIGTTOU); @@ -1185,12 +1185,60 @@ OsBlockSignals(void) #endif } +#ifdef SIG_BLOCK +static sig_atomic_t sigio_blocked; +#endif + +/** + * returns zero if this call caused SIGIO to be blocked now, non-zero if it + * was already blocked by a previous call to this function. + */ +int +OsBlockSIGIO(void) +{ +#ifdef SIGIO +#ifdef SIG_BLOCK + if (sigio_blocked++ == 0) { + sigset_t set, old; + int ret; + + sigemptyset(&set); + sigaddset(&set, SIGIO); + sigprocmask(SIG_BLOCK, &set, &old); + ret = sigismember(&old, SIGIO); + return ret; + } else + return 1; +#endif +#endif +} + +void +OsReleaseSIGIO(void) +{ +#ifdef SIGIO +#ifdef SIG_BLOCK + if (--sigio_blocked == 0) { + sigset_t set; + + sigemptyset(&set); + sigaddset(&set, SIGIO); + sigprocmask(SIG_UNBLOCK, &set, NULL); + } else if (sigio_blocked < 0) { + BUG_WARN(sigio_blocked < 0); + sigio_blocked = 0; + } +#endif +#endif +} + void OsReleaseSignals(void) { #ifdef SIG_BLOCK if (--BlockedSignalCount == 0) { sigprocmask(SIG_SETMASK, &PreviousSignalMask, 0); + OsReleaseSIGIO(); } #endif } |