Page MenuHome GnuPG

gpg on Solaris does not print a signal description
Closed, ResolvedPublic

Description

On GNU/Linux running gpg and clicking C-c to send SIGINT:

$ gpg
gpg: WARNING: no command supplied.  Trying to guess what you mean ...
gpg: Go ahead and type your message ...
^C
gpg: signal Interrupt caught ... exiting

The same thing on Solaris 11.4:

$ gpg
gpg: Warning: using insecure memory!
gpg: WARNING: no command supplied.  Trying to guess what you mean ...
gpg: Go ahead and type your message ...
^C
gpg: signal 2 caught ... exiting

This can be fixed by using _sys_siglist in get_signal_name from common/signal.c

Related Objects

Event Timeline

werner added a subscriber: werner.

The main problem here was that this all is not async-safe and thus I once implemented only the standard cases I could test easily.

FWIW, if gpg-agent etc we use npth (i.e. a pthread wrapper) which make signal handling much easier because it is then just an event and can be handled in your main thread or a separate thread.

Interesting, that sounds like a portable method. I am not very familiar with GPG internals, but to me that sounds like quite a bit of work. Unless there is another benefit to doing so, I don't think it is worth it just to print signal names.

The fallback to printing the number is reasonable, but using _sys_siglist on this platform saves you the time from opening errno.h to figure out what it maps too.

Right now we have

#elif HAVE_DECL_SYS_SIGLIST && defined(NSIG)
  return (signum >= 0 && signum < NSIG) ? sys_siglist[signum] : "?";
#else
  return NULL;

Can we use AC_CHECK_DECLS([_sys_siglist], to test for the Solaris case or do you think it is better to use a SUNOS or SOLARIS macro here? We could also use cpu-vendor-os triplet to define something in configure.ac.
Can we use

Hi Werner, I submitted a patch right after this bug report using AC_CHECK_DECLS([_sys_siglist]) [1].

Generally, I prefer checking for features in Autoconf rather than using OS detection since ./configure checks are less likely to break builds when building on older systems or future systems which may have changes we cannot account for. This is the same method Gnulib's version of strsignal does as well.

Though, doing #ifdef __sun would probably work, there is always the chance Illumos or Oracle Solaris gets rid of this interface.

[1] https://lists.gnupg.org/pipermail/gnupg-devel/2025-May/035872.html

werner claimed this task.