Index: ddd/LiterateA.C
--- ddd/LiterateA.C.orig	2004-06-07 13:52:53 +0200
+++ ddd/LiterateA.C	2005-03-17 08:51:48 +0100
@@ -216,8 +216,12 @@
     int flags = fcntl(fileno(fp), F_GETFL, 0);
     if (flags == -1)
 	_raiseIOWarning("cannot get file descriptor status flags");
-    if (fcntl(fileno(fp), F_SETFL, flags | O_NONBLOCK) == -1)
-	_raiseIOWarning("cannot set file to non-blocking mode");
+    if (fcntl(fileno(fp), F_SETFL, flags | O_NONBLOCK) == -1) {
+#if defined(__FreeBSD__)
+        if(errno != EAGAIN)
+#endif
+        _raiseIOWarning("cannot set file to non-blocking mode");
+    }
 #endif
 
     // Read stuff
@@ -251,8 +255,12 @@
 
 #if HAVE_FCNTL && defined(F_SETFL)
     // Reset file state
-    if (fcntl(fileno(fp), F_SETFL, flags) == -1)
-	_raiseIOWarning("cannot restore file mode");
+    if (fcntl(fileno(fp), F_SETFL, flags) == -1) {
+#if defined(__FreeBSD__)
+        if(errno != EAGAIN)
+#endif
+        _raiseIOWarning("cannot restore file mode");
+    }
 #endif
 
     return nitems;
Index: ddd/TTYAgent.C
--- ddd/TTYAgent.C.orig	2004-06-07 13:52:54 +0200
+++ ddd/TTYAgent.C	2005-03-17 08:51:48 +0100
@@ -715,8 +715,19 @@
     }
     else
     {
+#if !defined(__FreeBSD__)
 	if (fcntl(master, F_SETFL, flags | O_NONBLOCK) == -1)
 	    _raiseIOWarning("cannot set file to non-blocking mode");
+#else
+    do {
+        if (fcntl(master, F_SETFL, flags | O_NONBLOCK) != -1)
+            break;
+        else if(errno == EAGAIN)
+            sleep(1);
+        else 
+            _raiseIOWarning("cannot set file to non-blocking mode");
+   } while(errno == EAGAIN);
+#endif
     }
 #endif
 	
