$NetBSD: patch-aj,v 1.7 2015/08/14 20:58:41 joerg Exp $

--- plugins/r/src/tm_r.c.orig	2014-03-03 11:44:12.000000000 +0000
+++ plugins/r/src/tm_r.c
@@ -16,6 +16,7 @@
 #include <pty.h>
 #endif
 
+#include <util.h>
 #include <utmp.h>
 #include <unistd.h>
 #include <termios.h>
@@ -842,7 +843,11 @@ int main(int argc, char *argv[])
   char *TEXMACS_HOME_PATH, *TEXMACS_R, *TEXMACS_SEND_E, *TEXMACS_LIB, *HOME ;
   struct termios termi ;
   sigset_t sigmask, orig_sigmask;
-  
+#if defined(__DragonFly__)
+  sigset_t cur_sigmask;
+  int select_retval;
+#endif
+
   struct stat stat_buf;
 
   name = getenv("TEXMACS_R_SESSION") ;
@@ -1005,7 +1010,14 @@ unsetenv( "DYLD_LIBRARY_PATH") ;
 
       // We will wait till something happens using pselect.
 
+#if defined(__DragonFly__)
+      sigprocmask(SIG_SETMASK, &orig_sigmask, &cur_sigmask);
+      select_retval =  select( subprocess+1, &rd, &wr, &er, NULL );
+      sigprocmask(SIG_SETMASK, &cur_sigmask, NULL);
+      if ( select_retval > 0) {
+#else
       if( (pselect( subprocess+1, &rd, &wr, &er, NULL, &orig_sigmask )) > 0 ) {
+#endif
 	if( FD_ISSET( STDIN_FILENO, &er) ) exit(0) ;
 	if( FD_ISSET( STDOUT_FILENO, &er) ) exit(0) ;
 	if( FD_ISSET( subprocess, &er) ) exit(0) ;
