| To: | yyyyyyyyyyyyyy@xxxxxxxxxxxxx |
|---|---|
| Subject: | per-thread signal handlers (sigaction) |
| From: | Alexander Amelkin <yyyyyyyyyyy@xxxxxxxxxxxxxx> |
| Date: | Mon, 09 Jan 2006 18:43:07 +0300 |
|
Hello! Can anyone please clarify the situation with the signal handlers. It is unclear to me if POSIX requires only a single action for the process or allows every thread to set it's own action. POSIX says: "Each process has an action to be taken in response to each signal defined by the system" The sentence looks ambigous to me, as it does not directly disallow per-thread signal handlers. However, if I implement per-thread signal handlers, I have another questionable situation. POSIX says: "Setting a signal action to SIG_DFL for a signal that is pending, and whose default action is to ignore the signal (for example, SIGCHLD), shall cause the pending RTS signal to be discarded, whether or not it is blocked." and: "Setting a signal action to SIG_IGN for a signal that is pending shall cause the pending signal to be discarded, whether or not it is blocked." Now, imagine a scenario like this: 1. A process has multiple threads, each of them has a signal blocked. 2. The signal is sent asynchrounously using kill(), and thus is said to be "generated for a process". 3. According to POSIX the signal gets pending on the process, because there are no sigwaiters and everybody blocks it. 4. Some thread calls sigaction() to set an action for the signal to SIG_IGN. The thread intends to set the action for itself only (we have per-thread actions here, remember?) What should happen? Should the signal pending on the process get discarded or should it not? If the signal pending on the process is discarded, then it is never delivered to the process, although the thread intended to ignore the signal only for itself. Is that what was implied by the standard? Why? It looks to me like that must be clarified in the standard. For instance, it may be needed to add a flag to sigaction() to indicate a per-thread ignore. Or it should include an explicit prohibition of per-thread signal handlers. What do you think? With respect, Alexander. |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: printf(1) questions, David Hopwood |
|---|---|
| Next by Date: | per-thread signal handlers (sigaction), Alexander Amelkin |
| Previous by Thread: | printf(1) questions, Eric Blake |
| Next by Thread: | Re: per-thread signal handlers (sigaction), Ulrich Drepper |
| Indexes: | [Date] [Thread] [All Lists] |