[Konsole-devel] [Bug 164946] konsole hangs after inserting text
Urs Fleisch
ufleisch at users.sourceforge.net
Tue Nov 11 21:11:30 UTC 2008
http://bugs.kde.org/show_bug.cgi?id=164946
--- Comment #22 from Urs Fleisch <ufleisch users sourceforge net> 2008-11-11 22:11:30 ---
Hi,
The patch below sets the master PTY file descriptor to non-blocking mode and
handles the EAGAIN errors which are then possible. With that patch applied I
was able to paste large amounts of text into konsole without problems.
~~~~~~~~~
Index: kpty/kptydevice.cpp
===================================================================
--- kpty/kptydevice.cpp (revision 882922)
+++ kpty/kptydevice.cpp (working copy)
@@ -30,6 +30,7 @@
#include <klocale.h>
#include <unistd.h>
+#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include <termios.h>
@@ -273,7 +274,10 @@
char *ptr = readBuffer.reserve(available);
NO_INTR(readBytes, read(q->masterFd(), ptr, available));
if (readBytes < 0) {
- q->setErrorString(I18N_NOOP("Error reading from PTY"));
+ if (errno != EAGAIN) {
+ q->setErrorString(I18N_NOOP("Error reading from PTY"));
+ }
+ readBuffer.unreserve(available);
return false;
}
readBuffer.unreserve(available - readBytes); // *should* be a no-op
@@ -307,7 +311,11 @@
write(q->masterFd(),
writeBuffer.readPointer(), writeBuffer.readSize()));
if (wroteBytes < 0) {
- q->setErrorString(I18N_NOOP("Error writing to PTY"));
+ if (errno != EAGAIN) {
+ q->setErrorString(I18N_NOOP("Error writing to PTY"));
+ } else {
+ writeNotifier->setEnabled(true);
+ }
return false;
}
writeBuffer.free(wroteBytes);
@@ -419,6 +427,7 @@
readBuffer.clear();
readNotifier = new QSocketNotifier(q->masterFd(), QSocketNotifier::Read,
q);
writeNotifier = new QSocketNotifier(q->masterFd(), QSocketNotifier::Write,
q);
+ fcntl(q->masterFd(), F_SETFL, O_NONBLOCK);
QObject::connect(readNotifier, SIGNAL(activated(int)), q,
SLOT(_k_canRead()));
QObject::connect(writeNotifier, SIGNAL(activated(int)), q,
SLOT(_k_canWrite()));
readNotifier->setEnabled(true);
~~~~~~~~~
Regards,
Urs
--
Configure bugmail: http://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the konsole-devel
mailing list