Index: server/ptrace.c
@@ -36,6 +36,11 @@
 #ifndef PTRACE_POKEDATA
 #define PTRACE_POKEDATA PT_WRITE_D
 #endif
+#ifdef __FreeBSD__
+#define PTRACE_KEEPIP 1
+#else
+#define PTRACE_KEEPIP 0
+#endif
 
 static const int use_ptrace = 1;  /* set to 0 to disable ptrace */
 
@@ -64,10 +69,10 @@
             if (!thread)
                 if (!(thread = get_thread_from_pid( pid ))) break;
             if (!(thread->process->suspend + thread->suspend))
-                ptrace( PTRACE_CONT, pid, 0, sig );
+                ptrace( PTRACE_CONT, pid, PTRACE_KEEPIP, sig );
             break;
         default:  /* ignore other signals for now */
-            ptrace( PTRACE_CONT, pid, 0, sig );
+            ptrace( PTRACE_CONT, pid, PTRACE_KEEPIP, sig );
             break;
         }
         if (signal && sig != signal) goto restart;
@@ -97,7 +102,7 @@
 static int attach_thread( struct thread *thread )
 {
     /* this may fail if the client is already being debugged */
-    if (!use_ptrace || (ptrace( PTRACE_ATTACH, thread->unix_pid, 0, 0 ) == -1)) return 0;
+    if (!use_ptrace || (ptrace( PTRACE_ATTACH, thread->unix_pid, PTRACE_KEEPIP, 0 ) == -1)) return 0;
     if (debug_level) fprintf( stderr, "ptrace: attached to pid %d\n", thread->unix_pid );
     thread->attached = 1;
     wait4_thread( thread, SIGSTOP );
@@ -114,7 +119,7 @@
     {
         wait4_thread( thread, SIGTERM );
         if (debug_level) fprintf( stderr, "ptrace: detaching from %d\n", thread->unix_pid );
-        ptrace( PTRACE_DETACH, thread->unix_pid, 0, SIGTERM );
+        ptrace( PTRACE_DETACH, thread->unix_pid, PTRACE_KEEPIP, SIGTERM );
         thread->attached = 0;
     }
 }
@@ -137,7 +142,7 @@
 {
     if (!thread->unix_pid) return;
     if (!thread->attached) kill( thread->unix_pid, SIGCONT );
-    else ptrace( PTRACE_CONT, thread->unix_pid, 0, SIGSTOP );
+    else ptrace( PTRACE_CONT, thread->unix_pid, PTRACE_KEEPIP, SIGSTOP );
 }
 
 /* read an int from a thread address space */
