This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
pthread_sigaction() ?
- From: Xavier Roche <roche+kml2 at exalead dot com>
- To: libc-help at sourceware dot org
- Date: Wed, 18 May 2011 13:44:00 +0200
- Subject: pthread_sigaction() ?
Hi folks,
POSIX defines pthread_kill(pthread_t thread, int sig) to deliver a
signal to a specific thread.
But there is no way to handle it properly without overriding the global
signal handler ; ie. a given thread can not override locally the signal
handler for a specific purpose without a tight cooperation with the rest
of the process. And even with a cooperative process, handling a signal
differently for a given thread requires some acrobatic code (locking is
in theory forbidden as non signal-safe for example)
I was wondering why such function does not exist yet:
int pthread_sigaction_np(int signum, const struct sigaction *act,
struct sigaction *oldact);
(or
int pthread_sigaction_np(pthread_t thread, int signum,
const struct sigaction *act,
struct sigaction *oldact);
?)
Some considerations regarding priority of handlers would have to be
solved first ; it. sigation() handler vs. pthread_sigaction() handler
(the two could override each other depending on the ordering, for example)
Any thoughts on this ? No use case maybe ? [my use case was the ability
to locally handle signals to be able to siglongjmp() back to a defined
state on a given code section, without modifying the global signal handler]
(*)
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_kill.html>