about summary refs log tree commit diff
path: root/linuxthreads_db/td_thr_setgregs.c
diff options
context:
space:
mode:
Diffstat (limited to 'linuxthreads_db/td_thr_setgregs.c')
-rw-r--r--linuxthreads_db/td_thr_setgregs.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/linuxthreads_db/td_thr_setgregs.c b/linuxthreads_db/td_thr_setgregs.c
index 72f95b1ca7..50da111418 100644
--- a/linuxthreads_db/td_thr_setgregs.c
+++ b/linuxthreads_db/td_thr_setgregs.c
@@ -1,5 +1,5 @@
 /* Set a thread's general register set.
-   Copyright (C) 1999 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
 
@@ -34,9 +34,13 @@ td_thr_setgregs (const td_thrhandle_t *th, prgregset_t gregs)
     return TD_ERR;
 
   /* Only set the registers if the thread hasn't yet terminated.  */
-  if (pds.p_terminated == 0
-      && ps_lsetregs (th->th_ta_p->ph, pds.p_pid, gregs) != PS_OK)
-    return TD_ERR;
+  if (pds.p_terminated == 0)
+    {
+      pid_t pid = pds.p_pid ?: ps_getpid (th->th_ta_p->ph);
+
+      if (ps_lsetregs (th->th_ta_p->ph, pid, gregs) != PS_OK)
+	return TD_ERR;
+    }
 
   return TD_OK;
 }