Have threads and processes exit more cleanly whenever possible.
diff --git a/server/ptrace.c b/server/ptrace.c
index 9cd4c04..0346e72 100644
--- a/server/ptrace.c
+++ b/server/ptrace.c
@@ -117,21 +117,21 @@
}
/* detach from a Unix thread and kill it */
-void detach_thread( struct thread *thread )
+void detach_thread( struct thread *thread, int sig )
{
if (!thread->unix_pid) return;
if (thread->attached)
{
/* make sure it is stopped */
if (!(thread->suspend + thread->process->suspend)) stop_thread( thread );
- kill( thread->unix_pid, SIGTERM );
+ if (sig) kill( thread->unix_pid, sig );
if (debug_level) fprintf( stderr, "%08x: *detached*\n", (unsigned int)thread );
- ptrace( PTRACE_DETACH, thread->unix_pid, 1, SIGTERM );
+ ptrace( PTRACE_DETACH, thread->unix_pid, 1, sig );
thread->attached = 0;
}
else
{
- kill( thread->unix_pid, SIGTERM );
+ if (sig) kill( thread->unix_pid, sig );
if (thread->suspend + thread->process->suspend) continue_thread( thread );
}
}