You probably meant to say "enable" somewhere alongI think this is a misreading of the spec. The spec is saying thatBut my understanding differs.and posix seems to allow anyYes, long ago someone got confused, as I've noted in a recently added
other value for enable, which can be (on linux) SS_ONSTACK,
not only 0.
BUGS section in the page:
http://pubs.opengroup.org/onlinepubs/009695399/functions/sigaltstack.html
---
The /ss_flags/ member specifies the new stack state.
If it is set to SS_DISABLE, the stack is disabled and /ss_sp/
and /ss_size/ are ignored. Otherwise, the stack shall be enabled
---
As you can see, it doesn't say "SS_DISABLE or 0 are
only possible values". It does not even mention 0 at all
as being a possible or suggested value, it only uses it in
an example.
So what you call a confusion, looks valid to me, according
to the above spec.
(ss_flags & SS_DISABLE) != 0
means disable the stack and
(ss_flags & SS_DISABLE) == 0
means disable the stack.
POSIX.1 make no statement about the use of SS_ONSTACK to enable theUnfortunately the spec mentions only "SS_DISABLE"
stack.
And as far as I know, no other implementation attaches meaningI guess you take "SS_DISABLE is not set" as a witness that
to SS_ONSTACK when establishing a signal stack. Some systems' man
pages are loosely worded in the manner of POSIX, but others are quite
explicit, with Solaris 8 and Irix 6.5 containing text such as the
following:
If ss is not NULL, it points to a structure specifying the
alternate
signal stack that will take effect upon return from sigaltstack. [...]
The ss_flags field specifies the new stack state and may be set
to the following:
SS_DISABLE The stack is to be disabled and ss_sp and ss_size are
ignored. If SS_DISABLE is not set, the stack will be
enabled.
The strong implication there is that no value other than SS_DISABLE is
meaningful in ss.ss_flags. No other man page that I could find (and ISS_ONSTACK is meaningful in a sense to always be != SS_DISABLE.
have quite a collection) suggested the (ss.ss_flags == SSONSTACK) is
meaningful.
So, using SS_ONSTACK on Linux is a no-op that decreases codeHow about me supposing you use SS_DISABLE as a bitmask
portability. (And I am supposing that you use (ss.ss_flags ==
SS_ONSTACK) only because you've been misled into thinking its
legitimate from reading the kernel source.)
Another danger is someone trying to set up theI agree that it is an unusual scenario. But, user-space programmers[SIGA is delivered]Only if you deliver SIGB while still inside SIGA handler,
* Handler for SIGA is called and handler is executed on alternate SS 1.
]]
Summary: setting up another alternate signal stack seems to "work".
which is a bit unusual. Certainly not worth calling this
"works" IMHO. The fact that this will be undone at SIGA
exit, is much more confusing to the user, so I'd say just
don't do that.
outnumber kernel developers 10000 to 1, and over time they will find
every possible way to creatively use an API if it "works for them".
What do you mean?See my comment above. It's weird because it will disappear at exitAPI history is littered with stories where users found out thatIt will disappear at the exit from SIGA.
something unforeseen "worked", and so they used it. The question
is: what can go wrong if people do try using this "feature"?
To me this is "wrong enough" to not suggest doing so.
from SIGA, but not "wrong".
If you are going to add the scoped/nested sigaltstacks,The kernel already has the sigaltstack test-case,I must admit I'm still trying to grasp some details of what's
so maybe you can add some checks to it from your
test-case.
possible. What tests do you think could be usefully added?