diff mbox series

[ovs-dev,v1] signals: Add support for sigdescr_np

Message ID 20220322174257.280748-1-mkp@redhat.com
State Accepted
Commit 3a3a763349396227e184849a46a7949cead5e214
Headers show
Series [ovs-dev,v1] signals: Add support for sigdescr_np | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/intel-ovs-compilation success test: success
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

Mike Pattrick March 22, 2022, 5:42 p.m. UTC
In glibc 2.32 sys_siglist is no longer exported. The MT-safe function
sigdescr_np() is now available for the same purpose.

Signed-off-by: Mike Pattrick <mkp@redhat.com>
---
 configure.ac  | 1 +
 lib/signals.c | 5 +++++
 2 files changed, 6 insertions(+)

Comments

David Marchand March 23, 2022, 8:23 a.m. UTC | #1
On Tue, Mar 22, 2022 at 6:43 PM Mike Pattrick <mkp@redhat.com> wrote:
>
> In glibc 2.32 sys_siglist is no longer exported. The MT-safe function
> sigdescr_np() is now available for the same purpose.

I am not familiar with this, but a quick search returns:
https://www.gnu.org/software/gnulib/manual/html_node/sigdescr_005fnp.html

"""
Note: This function is hardly useful, because it returns English
strings, not internationalized strings. Better use the function
strsignal, which returns internationalized strings.
"""

Now reading strsignal manual, it seems to be POSIX, and a replacement
for direct access to sys_siglist... ?
Mike Pattrick March 23, 2022, 1:08 p.m. UTC | #2
On Wed, Mar 23, 2022 at 4:23 AM David Marchand
<david.marchand@redhat.com> wrote:
>
> On Tue, Mar 22, 2022 at 6:43 PM Mike Pattrick <mkp@redhat.com> wrote:
> >
> > In glibc 2.32 sys_siglist is no longer exported. The MT-safe function
> > sigdescr_np() is now available for the same purpose.
>
> I am not familiar with this, but a quick search returns:
> https://www.gnu.org/software/gnulib/manual/html_node/sigdescr_005fnp.html
>
> """
> Note: This function is hardly useful, because it returns English
> strings, not internationalized strings. Better use the function
> strsignal, which returns internationalized strings.
> """
>
> Now reading strsignal manual, it seems to be POSIX, and a replacement
> for direct access to sys_siglist... ?

Frustratingly, it's not MT safe.

-M

>
>
>
> --
> David marchand
>
David Marchand March 28, 2022, 1:55 p.m. UTC | #3
On Wed, Mar 23, 2022 at 2:08 PM Mike Pattrick <mkp@redhat.com> wrote:
>
> On Wed, Mar 23, 2022 at 4:23 AM David Marchand
> <david.marchand@redhat.com> wrote:
> >
> > On Tue, Mar 22, 2022 at 6:43 PM Mike Pattrick <mkp@redhat.com> wrote:
> > >
> > > In glibc 2.32 sys_siglist is no longer exported. The MT-safe function
> > > sigdescr_np() is now available for the same purpose.
> >
> > I am not familiar with this, but a quick search returns:
> > https://www.gnu.org/software/gnulib/manual/html_node/sigdescr_005fnp.html
> >
> > """
> > Note: This function is hardly useful, because it returns English
> > strings, not internationalized strings. Better use the function
> > strsignal, which returns internationalized strings.
> > """
> >
> > Now reading strsignal manual, it seems to be POSIX, and a replacement
> > for direct access to sys_siglist... ?
>
> Frustratingly, it's not MT safe.

Interesting...
And I found that there is a check for not adding strsignal in OVS too.


The change looks good to me.
I tested compilation only, on systems I have atm: i.e. RHEL7 (glibc
2.17), RHEL8 (glibc 2.28) and FC35 (glibc 2.34).


Reviewed-by: David Marchand <david.marchand@redhat.com>
Ilya Maximets April 4, 2022, 10:46 p.m. UTC | #4
On 3/28/22 15:55, David Marchand wrote:
> On Wed, Mar 23, 2022 at 2:08 PM Mike Pattrick <mkp@redhat.com> wrote:
>>
>> On Wed, Mar 23, 2022 at 4:23 AM David Marchand
>> <david.marchand@redhat.com> wrote:
>>>
>>> On Tue, Mar 22, 2022 at 6:43 PM Mike Pattrick <mkp@redhat.com> wrote:
>>>>
>>>> In glibc 2.32 sys_siglist is no longer exported. The MT-safe function
>>>> sigdescr_np() is now available for the same purpose.
>>>
>>> I am not familiar with this, but a quick search returns:
>>> https://www.gnu.org/software/gnulib/manual/html_node/sigdescr_005fnp.html
>>>
>>> """
>>> Note: This function is hardly useful, because it returns English
>>> strings, not internationalized strings. Better use the function
>>> strsignal, which returns internationalized strings.
>>> """
>>>
>>> Now reading strsignal manual, it seems to be POSIX, and a replacement
>>> for direct access to sys_siglist... ?
>>
>> Frustratingly, it's not MT safe.
> 
> Interesting...
> And I found that there is a check for not adding strsignal in OVS too.
> 
> 
> The change looks good to me.
> I tested compilation only, on systems I have atm: i.e. RHEL7 (glibc
> 2.17), RHEL8 (glibc 2.28) and FC35 (glibc 2.34).
> 
> 
> Reviewed-by: David Marchand <david.marchand@redhat.com>

Thanks!  Applied.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/configure.ac b/configure.ac
index 298ea85ab..a79109bda 100644
--- a/configure.ac
+++ b/configure.ac
@@ -101,6 +101,7 @@  OVS_CHECK_IF_DL
 OVS_CHECK_STRTOK_R
 OVS_CHECK_LINUX_AF_XDP
 AC_CHECK_DECLS([sys_siglist], [], [], [[#include <signal.h>]])
+AC_CHECK_FUNCS([sigdescr_np])
 AC_CHECK_DECLS([malloc_trim], [], [], [[#include <malloc.h>]])
 AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec, struct stat.st_mtimensec],
   [], [], [[#include <sys/stat.h>]])
diff --git a/lib/signals.c b/lib/signals.c
index 70c53adc6..1b3a80783 100644
--- a/lib/signals.c
+++ b/lib/signals.c
@@ -56,6 +56,11 @@  signal_name(int signum, char *namebuf, size_t bufsize)
             return name;
         }
     }
+#elif HAVE_SIGDESCR_NP
+    const char *name = sigdescr_np(signum);
+    if (name) {
+        return name;
+    }
 #endif
 
     snprintf(namebuf, bufsize, "signal %d", signum);