$NetBSD$

--- plugins/r/src/tm_r.c.orig	2007-05-15 17:54:35.000000000 +0000
+++ plugins/r/src/tm_r.c
@@ -11,7 +11,13 @@
 
 #include <stdio.h>
 #include <sys/select.h>
+#if defined(__DragonFly__) || defined(__FreeBSD__)
+#include <libutil.h>
+#elif defined(__NetBSD__) || defined(__OpenBSD__)
+#include <util.h>
+#else
 #include <pty.h>
+#endif
 #include <utmp.h>
 #include <unistd.h>
 #include <termios.h>
@@ -344,6 +350,10 @@ int main(int arc, char *argv[])
   char *TEXMACS_PATH, *TEXMACS_R, *TEXMACS_SEND, *TEXMACS_LIB ;
   struct termios termi ;
   sigset_t sigmask, orig_sigmask;
+#if defined(__DragonFly__)
+  sigset_t cur_sigmask;
+  int select_retval;
+#endif
 
   struct stat stat_buf;
 
@@ -466,7 +476,14 @@ int main(int arc, char *argv[])
 #endif
 
       /* Main pselect switch --------------- */
+#if defined(__DragonFly__)
+      sigprocmask(SIG_SETMASK, &orig_sigmask, &cur_sigmask);
+      select_retval =  select( master+1, &rd, &wr, &er, NULL );
+      sigprocmask(SIG_SETMASK, &cur_sigmask, NULL);
+      if ( select_retval > 0) {
+#else
       if( pselect( master+1, &rd, &wr, &er, NULL, &orig_sigmask ) > 0 ) {
+#endif
 	if( FD_ISSET( STDIN_FILENO, &rd ) ) {
 	  /* =============== read input from TeXmacs */
 	  nread = read_B( STDIN_FILENO, RB, 1000 ) ;
