Title: | DIGITAL UNIX (FORMERLY KNOWN AS DEC OSF/1) |
Notice: | Welcome to the Digital UNIX Conference |
Moderator: | SMURF::DENHAM |
Created: | Thu Mar 16 1995 |
Last Modified: | Fri Jun 06 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 10068 |
Total number of notes: | 35879 |
Hello, after the response given in note 8726.2, I have a concern about the sigwait call. In fact, I think that it is not reliable to use sigwait with a set of signals which contains more that 1 unique signal. Examine the following situation where a program has to deal with only 2 signals: . SIGINT -> to stop the process . SIGXCPU -> which could be used to manage a POSIX timer. * suppose that all the threads of the program have blocked these 2 signals from delivery * 1 service thread is in charge to "sigwait" these 2 signals and perform some processing. If the POSIX timer expires, the service thread will catch this signal, that is: . exit from the sigwait call . do something If during the "do something" a SIGINT signal is raised, this signal will be discarded because each thread (including the service thread) have this signal blocked. So the solution is to create 1 service thread for each signal that has to be processed. Then could someone tell me why the signature of sigwait allows this function to wait on multiple signals instead of waiting on only one signal ? Thanks in advance. /Pierre
T.R | Title | User | Personal Name | Date | Lines |
---|---|---|---|---|---|
8733.1 | DCETHD::BUTENHOF | Dave Butenhof, DECthreads | Thu Feb 06 1997 08:03 | 16 | |
>If during the "do something" a SIGINT signal is raised, this signal will >be discarded because each thread (including the service thread) have this >signal blocked. Your error is in assuming that the signal would be "discarded". It will remain pending until either SIGINT is unblocked in some thread, or some thread calls sigwait() specifying SIGINT as one of the signals. A signal is only discarded if it is already pending (assuming it's not set into queued signal mode), or if the signal action is set to "ignore" (SIG_IGN). Using sigwait to wait on multiple signals works just fine. There are some situations where you might want to use separate threads, though. For example, if processing some signal might take "a while", and you need to ensure rapid response to another signal. /dave |