[RFC] Consider adding a function to convert error name to errno

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Tue May 26 14:20:38 GMT 2026



On 25/05/26 05:58, Rocket Ma wrote:
> I ran into some problems when trying to implement str2sig. Since I
> want to write efficient code, I would like to reuse __sys_sigabbrev to
> map common signals like "ABRT" to SIGABRT, however, I noticed that
> some signals have aliases, for example, SIGABRT == SIGIOT. As I can't
> lookup __sys_sigabbrev[SIGIOT] to get "IOT", it's hard not to write
> some work around to accept signal aliases. I also noticed that on
> Linux, glibc takes 32 and 33 as SIGCANCEL and SIGSETXID, and increases
> RTMIN by 2.
> 
> For the first question, the alias one, I would ask is there a graceful
> solution when constructing array with X-macro but some indexes are
> conflict? I got no idea on how to put SIGIOT and SIGABRT in the same
> array and separate them when needed. Some ugly work around like
> applying `SIGIOT | 0x40` as index increases array size.

For this I think the straightforward solution would keep a separate alias
table (name -> number) for both canonical and alias variants. Check
"IOT" in the alias table, find SIGABRT, then resolve to the canonical 
abbreviation if needed.

I am assuming the alias table will be small, so we can just make a linear
search all the time.

Another possibility would to extend __sys_sigabbrev to store the aliases
as well. But this is consume more memory, but be straightforward.

I would check the the alias first.

> 
> For the second question, the glibc private signal, I would ask shall
> we map 32 to SIGCANCEL and map "CANCEL" back to 32 in sig2str/str2sig?
> If we don't do this, user may observe that RTMIN starts from 34
> instead of 32 and oddly find that 2 signals are undefined.
My understanding is sig2str should return -1 for 32 (SIGCANCEL) and
33 (SIGSETXID), even though these value are not handling as EINVAL
for kill().  My understanding is POSIX code should only issues kill()
with the values from signal.h, including RTMIN ones; and SIGCANCEL
and SIGSETXID are an implementation detail.



More information about the Libc-alpha mailing list