Skip to content

Commit

Permalink
set siginterrupt flag to False
Browse files Browse the repository at this point in the history
This patch sets the siginterrupt flag to False so that interrupted system calls
are automatically restarted. This notably fixes applications using the Precice
coupling library, which does not currently handle EINTR read errors. This patch
also changes the unit tests to SIGINT-based control, so that signal handlers
are not blocked while waiting for user input.
  • Loading branch information
gertjanvanzwieten committed Sep 28, 2022
1 parent efd49b7 commit fd2dc3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions bottombar.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ def __init__(self, handler: Callable[[], None]) -> None:
if signal.getsignal(sig) != signal.SIG_DFL:
raise RuntimeError(f'signal {sig.name} is in use')
signal.signal(sig, lambda sig, frame: handler())
signal.siginterrupt(sig, False) # restart any interrupted system calls
signal.setitimer(signal.ITIMER_REAL, 0.)
_debug('started signal based auto-redraw handler')
def set(self, refresh: float) -> None:
Expand Down
11 changes: 11 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import bottombar as bb, os, time
import signal

def input(msg):
print(msg, end='', flush=True)
while True:
try:
signal.pause()
except KeyboardInterrupt:
break
print()

print('\033[{};1H'.format(os.get_terminal_size().lines))
print('====================')
print('BOTTOMBAR UNIT TESTS')
print('--------------------')
print('PRESS CTRL+C TO PROCEED TO THE NEXT TEST')

print('1. basic terminal tests')
input(' a. check that this question shows at the very last line')
Expand Down

0 comments on commit fd2dc3a

Please sign in to comment.