[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: pthread_kill is racy: probably needs kernel change



> @@ -31,6 +31,10 @@ pthread_kill (threadid, signo)
>  {
>    struct pthread *pd = (struct pthread *) threadid;
>  
> +  /* Don't call the kernel just to check if it's running */
> +  if(!signo)
> +	  return pd->tid ? 0 : ESRCH;
> +  
>    /* We have a special syscall to do the work.  */
> -  return INLINE_SYSCALL (tkill, 2, pd->tid, signo);
> +  return -INLINE_SYSCALL (tkilldet, 2, &pd->tid, signo);
>  }

Oops, this is broken, since INLINE_SYSCALL sets errno.

Replace with this:

@@ -31,6 +31,10 @@ pthread_kill (threadid, signo)
 {
   struct pthread *pd = (struct pthread *) threadid;
 
+  /* Don't call the kernel just to check if it's running */
+  if(!signo)
+	  return pd->tid ? 0 : ESRCH;
+  
   /* We have a special syscall to do the work.  */
-  return INLINE_SYSCALL (tkill, 2, pd->tid, signo);
+  return INLINE_SYSCALL (tkilldet, 2, &pd->tid, signo) ? errno : 0;
 }

Attachment: pgp00043.pgp
Description: PGP signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]