> > Yes, this is a bug in the application -- but it's interesting that this
> > bug only shows up when you try to integrate a new, well-behaved, library
> > into the app. It's a fragile part of the Unix API. sigopen() is
> > a way for libraries to defend themselves against misuse of sigwaitinfo()
> > by big applications over which you have no control.
> >
> > So sigopen() is a technological fix to a social problem, I guess.
>
> Requiring all libraries to use the sigopen() as you specified it just
> isn't going to work, because you would have to make big changes to the
> libraries.
I didn't mean to require any library to change at all. This is
an optional thing; a library can use this technique if it wants to
insulate itself from badly behaved applications.
> Sometimes you actually do need SIGRTxxx signals to be delivered using
> signal handlers!
No objection there, I agree.
> Also as it was specified, you are reduced to reading one type of signal
> at a time, or using select(). Often you wish to check several signals.
> For example, in my programs sigwaitinfo() calls check for SIGIO, SIGURG
> and SIGRTxxx at least. Therefore siginfo(), if implemented, should take
> a sigset_t, not a signal number.
I have no objection to sigopen() taking a sigset_t *.
> The problem of when you actually want to receive an allocated signal
> through a handler is, IMHO, best solved by permitting sigaction() and
> signal delivery on signals that have been opened with sigopen().
sigopen() essentially installs a special signal handler (say, SIG_OPEN).
If sigaction() can override that, it should probably close the file descriptor, too.
I can buy that, perhaps, even though it makes libraries using sigopen()
somewhat more vulnerable to poorly behaved applications. I think the
present application doesn't misbehave badly enough that it would try to
install a signal handler over Chris's.
> However, it would be ok to require a flag SA_SIGOPEN to sigaction() to
> prevent it from returning EBUSY.
That'd be ok.
Another issue someone raised:
> would read() on this fd require the kernel to copy every byte of the siginfo_t?
IMHO no; read() would leave undefined any bytes that would not have been set by
sigwaitinfo(). The kernel could set them to zero or leave them untouched,
as desired.
Another issue:
AFAIK, there's no 'read with a timeout' system call for file descriptors, so
if you needed the equivalent of sigtimedwait(),
you might end up doing a select on the sigopen fd, which is an extra
system call. (I wish Posix had invented sigopen() and readtimedwait() instead of
sigtimedwait...)
- Dan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/