[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: concurrent access
Will Lockhart wrote:
> As to the signals and threads issue, this is what I know so far:
>
> Under Linux, each thread does indeed have its own PID. Signals can be
> delivered to a specific process ID, and therefore, a signal which is
> delivered to a process will be delivered to a specific thread in that
> process. This is consistent with the POSIX standard, that says that
> signals that are delivered to a process are delivered to an arbitrary
> thread in that process. (However, this also leads to a situation where
> LinuxThreads are not POSIX compliant - the POSIX standard says that if
> a signal is delivered to a thread which is blocking that signal, but
> there is another thread which is not blocking the signal, the second
> thread will receive the signal. This does not happen with Linux - the
> signal will simply not be delivered at in this situation).
>
> The correct POSIX way to handle this situation is to block the signal
> in all threads, then sigwait for it in a thread dedicated to catching
> the signal. So I block the SIGIO signal in all my threads, create a
> new thread, use fcntl to tell the driver to deliver signals to that
> thread and use sigwait to wait for the signal to arrive and.... it
> doesn't work :(
In my threaded application I do not block the SIGIO signal in the rest of the
threads, but install the handler that is to handle the signal from within the
main thread. It works for me.
Cheers,
R.Cantarutti