From 1e3660bf5fec378c859ca8909787a7769e9b85ba Mon Sep 17 00:00:00 2001 From: EulerOSWander <314264452@qq.com> Date: Sat, 27 Feb 2021 17:09:02 +0800 Subject: [PATCH] Sync patches from upstream Sync patches from upstream Signed-off-by: EulerOSWander <314264452@qq.com> --- backport-0011-pgrep-Remove-memory-leak.patch | 34 +++++++++++++++++ ...to-avoid-repeated-stat-etc-localtime.patch | 37 +++++++++++++++++++ ...-argument-handling-for-negative-PIDs.patch | 25 +++++++++++++ procps-ng.spec | 14 +++++-- 4 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 backport-0011-pgrep-Remove-memory-leak.patch create mode 100644 backport-0012-Set-TZ-to-avoid-repeated-stat-etc-localtime.patch create mode 100644 backport-0013-kill-Fix-argument-handling-for-negative-PIDs.patch diff --git a/backport-0011-pgrep-Remove-memory-leak.patch b/backport-0011-pgrep-Remove-memory-leak.patch new file mode 100644 index 0000000..ff01277 --- /dev/null +++ b/backport-0011-pgrep-Remove-memory-leak.patch @@ -0,0 +1,34 @@ +From 5f859b30d34c3e1ec3fca48d55248b502669fcc5 Mon Sep 17 00:00:00 2001 +From: Craig Small +Date: Tue, 22 Dec 2020 16:08:49 +1100 +Subject: [PATCH] pgrep: Remove memory leak + +This is part of !118 where @tt.rantala found a memory leak. +The other part of !118 may come later if the performance change +is significant. + +References: + procps-ng/procps!118 +--- + pgrep.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/pgrep.c b/pgrep.c +index 205a1db..4fe5e8a 100644 +--- a/pgrep.c ++++ b/pgrep.c +@@ -716,6 +716,11 @@ static struct el * select_procs (int *num) + free(cmdsearch); + free(cmdoutput); + ++ if (preg) { ++ regfree(preg); ++ free(preg); ++ } ++ + return list; + } + +-- +2.27.0 + diff --git a/backport-0012-Set-TZ-to-avoid-repeated-stat-etc-localtime.patch b/backport-0012-Set-TZ-to-avoid-repeated-stat-etc-localtime.patch new file mode 100644 index 0000000..1ad194a --- /dev/null +++ b/backport-0012-Set-TZ-to-avoid-repeated-stat-etc-localtime.patch @@ -0,0 +1,37 @@ +From 31343570e17cb13605c2c5a5c8b9a21d443bbb2a Mon Sep 17 00:00:00 2001 +From: Stephen Brennan +Date: Thu, 19 Nov 2020 16:03:58 -0800 +Subject: [PATCH] Set TZ to avoid repeated stat("/etc/localtime") + +With glibc, each time the strftime() function is used (twice per process +in a typical ps -fe run), a stat("/etc/localtime") system call is used +to determine the timezone. Not only does this add extra system call +overhead, but when multiple ps processes are trying to access this +file (or multiple glibc programs using strftime) in parallel, this can +trigger significant lock contention within the OS kernel. + +Since ps is not intended to run for long periods of time as a +daemon (during which the system timezone could be altered and PS might +reasonably be expected to adapt its output), there is no benefit to +repeatedly doing this stat(). To stop this behavior, explicitly set the +TZ variable to its default value (:/etc/localtime) whenever it is unset. +glibc will then cache the stat() result. +--- + ps/display.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/ps/display.c b/ps/display.c +index 95a55c3..06094d3 100644 +--- a/ps/display.c ++++ b/ps/display.c +@@ -633,6 +633,7 @@ int main(int argc, char *argv[]){ + setlocale (LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); ++ setenv("TZ", ":/etc/localtime", 0); + + #ifdef DEBUG + init_stack_trace(argv[0]); +-- +2.27.0 + diff --git a/backport-0013-kill-Fix-argument-handling-for-negative-PIDs.patch b/backport-0013-kill-Fix-argument-handling-for-negative-PIDs.patch new file mode 100644 index 0000000..d4d0102 --- /dev/null +++ b/backport-0013-kill-Fix-argument-handling-for-negative-PIDs.patch @@ -0,0 +1,25 @@ +From 79097e55e4b08ec8c1de8332e32cf03c4be1d4ec Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rapha=C3=ABl=20Jakse?= +Date: Fri, 7 Sep 2018 12:57:03 +0000 +Subject: [PATCH] kill: Fix argument handling for negative PIDs + +--- + skill.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/skill.c b/skill.c +index 5a79a41..38ebdc5 100644 +--- a/skill.c ++++ b/skill.c +@@ -507,7 +507,7 @@ static void __attribute__ ((__noreturn__)) + } else { + /* Special case for signal digit negative + * PIDs */ +- pid = atoi(argv[optind]); ++ pid = atoi(argv[optind-1]); + if (kill((pid_t)pid, signo) != 0) + exitvalue = EXIT_FAILURE; + exit(exitvalue); +-- +2.27.0 + diff --git a/procps-ng.spec b/procps-ng.spec index fceadfe..fdf732e 100644 --- a/procps-ng.spec +++ b/procps-ng.spec @@ -1,6 +1,6 @@ Name: procps-ng Version: 3.3.16 -Release: 16 +Release: 17 Summary: Utilities that provide system information. License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+ URL: https://sourceforge.net/projects/procps-ng/ @@ -19,6 +19,9 @@ Patch0006: backport-0007-Fixes-small-bug-in-struct-proc_t-documentation.patch Patch0007: backport-0008-misc-eliminate-a-couple-of-miscellaneous-gcc-warning.patch Patch0008: backport-0009-top-fix-potential-SEGV-when-no-tasks-were-displayabl.patch Patch0009: backport-0010-top-fix-additional-SEGVs-if-no-tasks-were-displayabl.patch +Patch0010: backport-0011-pgrep-Remove-memory-leak.patch +Patch0011: backport-0012-Set-TZ-to-avoid-repeated-stat-etc-localtime.patch +Patch0012: backport-0013-kill-Fix-argument-handling-for-negative-PIDs.patch Patch9000: feature-add-options-M-and-N-for-top.patch Patch9001: bugfix-top-exit-with-error-when-pid-overflow.patch @@ -104,13 +107,16 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof %{_mandir}/translated %changelog -* Mon Feb 08 2020 xinghe - 3.3.16-16 +* Sat Feb 27 2021 xinghe - 3.3.16-17 +-Sync patches from upstream + +* Mon Feb 08 2021 xinghe - 3.3.16-16 - rebuild package -* Mon Feb 08 2020 xinghe - 3.3.16-15 +* Mon Feb 08 2021 xinghe - 3.3.16-15 - rebuild package -* Mon Feb 08 2020 xinghe - 3.3.16-14 +* Mon Feb 08 2021 xinghe - 3.3.16-14 - rebuild package * Thu Nov 03 2020 xinghe - 3.3.16-13 -- Gitee