pthread_sigqueue{_np} ??
Bharadwaj Yadavalli
sby@ives.lkg.dec.com
Thu Feb 8 09:36:00 GMT 2001
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
More information about the Libc-alpha
mailing list