This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

pthread_sigqueue{_np} ??



Thanks Andreas Jaeger for pointing me to the right 
implementation of sigqueue.

Now that I know (and verified) that sigqueue() is
implemented in glibc I am wondering if it makes sense
to implement pthread_sigqueue() (or pthread_sigqueue_np
since pthread_sigqueue() is not a defined interface 
in POSIX). By this interface we would get all the 
advantages of using sigqueue on a thread. (I do realize
on Linux, a thread is a clone()'d process and all).
Consequent to a brief look at the code for pthread_kill()
in linuxthreads/signals.c the following adaptation would
do the job.

int pthread_sigqueue_np(pthread_t thread,
			int signo, 
                        const union sigval val)
{
  pthread_handle handle = thread_handle(thread);
  int pid;

  __pthread_lock(&handle->h_lock, NULL);
  if (invalid_handle(handle, thread)) {
    __pthread_unlock(&handle->h_lock);
    return ESRCH;
  }
  pid = handle->h_descr->p_pid;
  __pthread_unlock(&handle->h_lock);
  if (sigqueue(pid, signo, val) == -1)
    return errno;
  else
    return 0;
}

Comments?

Bharadwaj

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]