Skip to content

Commit

Permalink
Verify ioctl return value in jansi
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Mar 8, 2023
1 parent 362b233 commit f3fa703
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,20 @@ protected void doSetAttr(Attributes attr) throws IOException {
@Override
public Size getSize() throws IOException {
CLibrary.WinSize sz = new CLibrary.WinSize();
CLibrary.ioctl(slave, CLibrary.TIOCGWINSZ, sz);
int res = CLibrary.ioctl(slave, CLibrary.TIOCGWINSZ, sz);
if (res != 0) {
throw new IOException("Error calling ioctl(TIOCGWINSZ): return code is " + res);
}
return new Size(sz.ws_col, sz.ws_row);
}

@Override
public void setSize(Size size) throws IOException {
CLibrary.WinSize sz = new CLibrary.WinSize((short) size.getRows(), (short) size.getColumns());
CLibrary.ioctl(slave, CLibrary.TIOCSWINSZ, sz);
int res = CLibrary.ioctl(slave, CLibrary.TIOCSWINSZ, sz);
if (res != 0) {
throw new IOException("Error calling ioctl(TIOCSWINSZ): return code is " + res);
}
}

protected abstract CLibrary.Termios toTermios(Attributes t);
Expand Down

0 comments on commit f3fa703

Please sign in to comment.