Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Proposal: new libc/libutil functions to map SIGXXXX <-> "XXXX"



In article <19292.1493388872%andromeda.noi.kre.to@localhost>,
Robert Elz  <kre%munnari.OZ.AU@localhost> wrote:
>    Date:        Fri, 28 Apr 2017 11:38:38 +0000 (UTC)
>    From:        christos%astron.com@localhost (Christos Zoulas)
>    Message-ID:  <odv9ju$c83$1%blaine.gmane.org@localhost>
>
>  | Perhaps signame() -> strsignal_r()?
>
>Uh, no, strsignal() (while it could probably do with an _r variant)
>is something quite different  - it returns "emulator trap" (or something)
>in a locale dependent way, where the new function returns "EMT", given
>that SIGEMT is the signal number handed to both.

Ah ok.

>I'm not sure I'm competent to deal with locale using functions,
>or I'd probably have suggested a thread safe version of strsignal()
>as well.   (Or rather, I'm sure I'm not competent...)

Yes, leave it.

>However, in an off-list message (which I asked him to repeat on list,
>but which has not happened yet) Kamil did indicate that the names I
>picked conflict (badly for signame) with names used (presumably for
>other things) in other software, so we do probably need something
>different...  perhaps signal_name() and signal_number() ?

Well, I am sure that whatever we pick that is reasonable at this point
will bound to conflict with something else so I prefer to pick the
best names for the job instead :-)

>Joerg Sonnenberger <jjoerg%bec.de@localhost> said:
>
>   | I'd call it signalnumber and signalname,
>
>those names would be fine too (assuming they're not in wide use elsewhere...)

sure, those work too.

>   | I'd just make it
>   |     const char *signame(int sig) __pure
>
>That would certainly simplify it a bit (but what does __pure mean?   And
>if there, would that be in the man page, or just the code? (.c & .h) .. and
>if in the man page, does anyone know the markup method to accomplish that?)

Pure means that it will return the same value given the same argument, for
example sqrt() is pure. Pure functions can be cached.

I am not sure about making it pure though; how about if you pass a signal
number that does not exist? Should it return "Unknown signal", or
"Unknown signal %d". Certainly the second is better but it needs a static
buffer... I think I prefer orthogonality here; make it like strerror()
and strerror_r()?  strsigname() and strsigname_r()?

christos



Home | Main Index | Thread Index | Old Index