Skip to content

Commit

Permalink
Fix int signal #140
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Jan 8, 2018
1 parent fc908f3 commit 7df08fb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.io.IOError;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.nio.charset.Charset;
import java.util.EnumSet;
import java.util.HashMap;
Expand Down Expand Up @@ -205,4 +206,9 @@ public MouseEvent readMouseEvent(IntSupplier reader) {
return lastMouseEvent = MouseSupport.readMouse(reader, lastMouseEvent);
}

protected void checkInterrupted() throws InterruptedIOException {
if (Thread.interrupted()) {
throw new InterruptedIOException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class PosixInputStream extends NonBlockingInputStream {

@Override
public int read(long timeout, boolean isPeek) throws IOException {
checkInterrupted();
if (c != 0) {
int r = c;
if (!isPeek) {
Expand All @@ -138,6 +139,7 @@ public int read(long timeout, boolean isPeek) throws IOException {
}
return r;
}
checkInterrupted();
long cur = System.currentTimeMillis();
if (timeout > 0 && cur - start > timeout) {
return NonBlockingInputStream.READ_EXPIRED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class PosixInputStream extends NonBlockingInputStream {

@Override
public int read(long timeout, boolean isPeek) throws IOException {
checkInterrupted();
if (c != 0) {
int r = c;
if (!isPeek) {
Expand All @@ -151,6 +152,7 @@ public int read(long timeout, boolean isPeek) throws IOException {
}
return r;
}
checkInterrupted();
long cur = System.currentTimeMillis();
if (timeout > 0 && cur - start > timeout) {
return NonBlockingInputStream.READ_EXPIRED;
Expand Down

0 comments on commit 7df08fb

Please sign in to comment.