Check read() return value in getCursorPosition().