procps-ng/SOURCES/display-sig-unsafe.patch
2023-05-09 08:22:25 +00:00

45 lines
1.3 KiB
Diff

diff -up ./ps/display.c.ori ./ps/display.c
--- ./ps/display.c.ori 2021-02-09 11:11:25.000000000 +0100
+++ ./ps/display.c 2022-11-29 18:39:13.254573784 +0100
@@ -44,6 +44,8 @@
#define SIGCHLD SIGCLD
#endif
+#define SIG_IS_TERM_OR_HUP(signo) (((signo) == SIGTERM) || (signo) == SIGHUP)
+
char *myname;
/* just reports a crash */
@@ -54,20 +56,23 @@ static void signal_handler(int signo){
sigprocmask(SIG_BLOCK, &ss, NULL);
if(signo==SIGPIPE) _exit(0); /* "ps | head" will cause this */
/* fprintf() is not reentrant, but we _exit() anyway */
- fprintf(stderr,
- _("Signal %d (%s) caught by %s (%s).\n"),
- signo,
- signal_number_to_name(signo),
- myname,
- PACKAGE_VERSION
- );
+ if (!SIG_IS_TERM_OR_HUP(signo)) {
+ fprintf(stderr,
+ _("Signal %d (%s) caught by %s (%s).\n"),
+ signo,
+ signal_number_to_name(signo),
+ myname,
+ PACKAGE_VERSION
+ );
+ }
switch (signo) {
case SIGHUP:
case SIGUSR1:
case SIGUSR2:
exit(EXIT_FAILURE);
default:
- error_at_line(0, 0, __FILE__, __LINE__, "%s", _("please report this bug"));
+ if (!SIG_IS_TERM_OR_HUP(signo))
+ error_at_line(0, 0, __FILE__, __LINE__, "%s", _("please report this bug"));
signal(signo, SIG_DFL); /* allow core file creation */
sigemptyset(&ss);
sigaddset(&ss, signo);