]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix the tkill system call wrapper and enable it on x86 and amd64.
authorTom Hughes <tom@compton.nu>
Wed, 15 Feb 2006 10:34:50 +0000 (10:34 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 15 Feb 2006 10:34:50 +0000 (10:34 +0000)
Fixes bug #121901.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5651

coregrind/m_syswrap/syswrap-amd64-linux.c
coregrind/m_syswrap/syswrap-linux.c
coregrind/m_syswrap/syswrap-x86-linux.c

index 5d879ad132c9bce8ea492c0ff7e4451e18279ca1..4e6bd6ea267c2dae768da4b478dea66ebe47bd1f 100644 (file)
@@ -1204,7 +1204,7 @@ const SyscallTableEntry ML_(syscall_table)[] = {
    LINX_(__NR_lremovexattr,      sys_lremovexattr),   // 198 
    LINX_(__NR_fremovexattr,      sys_fremovexattr),   // 199 
 
-   //   (__NR_tkill,             sys_tkill),             // 200 
+   LINXY(__NR_tkill,             sys_tkill),             // 200 
    GENXY(__NR_time,              sys_time), /*was sys_time64*/ // 201 
    LINXY(__NR_futex,             sys_futex),             // 202 
    LINX_(__NR_sched_setaffinity, sys_sched_setaffinity), // 203 
index c6587c71941be97a15fd847d960417ad3bd1b5df..3ceebf25d3ae66f9fec94a8138f53087fba96e46 100644 (file)
@@ -867,29 +867,46 @@ PRE(sys_set_tid_address)
    PRE_REG_READ1(long, "set_tid_address", int *, tidptr);
 }
 
-//zz PRE(sys_tkill, Special)
-//zz {
-//zz    /* int tkill(pid_t tid, int sig); */
-//zz    PRINT("sys_tkill ( %d, %d )", ARG1,ARG2);
-//zz    PRE_REG_READ2(long, "tkill", int, tid, int, sig);
-//zz    if (!ML_(client_signal_OK)(ARG2)) {
-//zz       SET_STATUS_( -VKI_EINVAL );
-//zz       return;
-//zz    }
-//zz 
-//zz    /* If we're sending SIGKILL, check to see if the target is one of
-//zz       our threads and handle it specially. */
-//zz    if (ARG2 == VKI_SIGKILL && ML_(do_sigkill)(ARG1, -1))
-//zz       SET_STATUS_(0);
-//zz    else
-//zz       SET_STATUS_(VG_(do_syscall2)(SYSNO, ARG1, ARG2));
-//zz 
-//zz    if (VG_(clo_trace_signals))
-//zz       VG_(message)(Vg_DebugMsg, "tkill: sent signal %d to pid %d",
-//zz              ARG2, ARG1);
-//zz    // Check to see if this kill gave us a pending signal
-//zz    XXX FIXME VG_(poll_signals)(tid);
-//zz }
+PRE(sys_tkill)
+{
+   PRINT("sys_tgkill ( %d, %d )", ARG1,ARG2);
+   PRE_REG_READ2(long, "tkill", int, tid, int, sig);
+   if (!ML_(client_signal_OK)(ARG2)) {
+      SET_STATUS_Failure( VKI_EINVAL );
+      return;
+   }
+   
+   /* Check to see if this kill gave us a pending signal */
+   *flags |= SfPollAfter;
+
+   if (VG_(clo_trace_signals))
+      VG_(message)(Vg_DebugMsg, "tkill: sending signal %d to pid %d",
+                  ARG2, ARG1);
+
+   /* If we're sending SIGKILL, check to see if the target is one of
+      our threads and handle it specially. */
+   if (ARG2 == VKI_SIGKILL && ML_(do_sigkill)(ARG1, -1)) {
+      SET_STATUS_Success(0);
+      return;
+   }
+
+   /* Ask to handle this syscall via the slow route, since that's the
+      only one that sets tst->status to VgTs_WaitSys.  If the result
+      of doing the syscall is an immediate run of
+      async_signalhandler() in m_signals, then we need the thread to
+      be properly tidied away.  I have the impression the previous
+      version of this wrapper worked on x86/amd64 only because the
+      kernel did not immediately deliver the async signal to this
+      thread (on ppc it did, which broke the assertion re tst->status
+      at the top of async_signalhandler()). */
+   *flags |= SfMayBlock;
+}
+POST(sys_tkill)
+{
+   if (VG_(clo_trace_signals))
+      VG_(message)(Vg_DebugMsg, "tkill: sent signal %d to pid %d",
+                   ARG2, ARG1);
+}
 
 PRE(sys_tgkill)
 {
index e277efe77912290e3c816a0c82b71a940e8f4fb0..4861a7c685638d70dac75ab23be926feeaaa00ba 100644 (file)
@@ -2050,7 +2050,7 @@ const SyscallTableEntry ML_(syscall_table)[] = {
    LINX_(__NR_removexattr,       sys_removexattr),    // 235
    LINX_(__NR_lremovexattr,      sys_lremovexattr),   // 236
    LINX_(__NR_fremovexattr,      sys_fremovexattr),   // 237
-//zz    LINX_(__NR_tkill,             sys_tkill),          // 238 */Linux
+   LINXY(__NR_tkill,             sys_tkill),          // 238 */Linux
    LINXY(__NR_sendfile64,        sys_sendfile64),     // 239
 
    LINXY(__NR_futex,             sys_futex),             // 240