pthread_kill ESRCH

Bug #374769 reported by Angelo Borsotti on 2009-05-11
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libpthread-stubs (Ubuntu)
Medium
Unassigned

Bug Description

Man page of pthread_kill:
...
  The pthread_kill function returns the following error codes on error:

              EINVAL signo is not a valid signal number
              ESRCH the thread thread does not exist (e.g. it has already
                     terminated)

Compile and run the following program (errkill.c):

#include <pthread.h>
#include <stdio.h>
#include <string.h>

void* victim(void* data){
    return NULL;
}

main (){
    pthread_t th;
    int err;
    pthread_create(&th,NULL,victim,0);
    pthread_join(th,NULL);
    if (err = pthread_kill(th,0) != 0){
        printf("pthread_kill %s\n",strerror(err));
    }
}

$ gcc errkill.c -o errkill.exe -lpthread
$ ./errkill.exe
pthread_kill Operation not permitted

I.e. pthread_kill returns EPERM instead of ESRCH
Then, either the documentation or the library function is wrong.
I think that ESRCH is the correct error to report.

Ubuntu version: 9.04

Charlie Kravetz (charlie-tca) wrote :

Thank you for reporting this issue. Can you tell me what application this is you are building? Where did it come from? If I have never tried this application, what steps do I follow to get this bug to reproduce for me?

Thanks again.

Changed in ubuntu:
status: New → Incomplete

Charlie,

I have isolated the bug that occurred in a large application into a small
file, that I have included in my problem report.
In case you have not received it, here is the file again. Copy it into a
text editor window, save it as errkill.c, compile and run it: you will
see that the program prints the message corresponding to EPERM
instead of that of ESRCH, contrarily to what the man page of
pthread_join states:

------------------------file errkill.c-----------------------------------------
#include <pthread.h>
#include <stdio.h>
#include <string.h>

void* victim(void* data){
   return NULL;
}

main (){
   pthread_t th;
   int err;
   pthread_create(&th,NULL,victim,0);
   pthread_join(th,NULL);
   if (err = pthread_kill(th,0) != 0){
       printf("pthread_kill %s\n",strerror(err));
   }
}
----------------------------end of file--------------------------------------

$ gcc errkill.c -o errkill.exe -lpthread
$ ./errkill.exe
pthread_kill Operation not permitted

Why this bug is marked "incomplete"? Is any information missing?

Charlie Kravetz (charlie-tca) wrote :

Thanks for reporting this bug and any supporting documentation. Since this bug has enough information provided for a developer to begin work, I'm going to mark it as confirmed and let them handle it from here. Thanks for taking the time to make Ubuntu better!

affects: ubuntu → libpthread-stubs (Ubuntu)
Changed in libpthread-stubs (Ubuntu):
importance: Undecided → Medium
status: Incomplete → Triaged
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers