diff --git a/0001-add-M-and-N-options-for-top.patch b/0001-add-M-and-N-options-for-top.patch new file mode 100644 index 0000000000000000000000000000000000000000..b21b67a4c61d4bec2895c9bcf13a01fbd4bd142b --- /dev/null +++ b/0001-add-M-and-N-options-for-top.patch @@ -0,0 +1,68 @@ +From 6e59f5e746c15df4d4b53f2df85b64aa1f10d0c3 Mon Sep 17 00:00:00 2001 +From: xuchunmei +Date: Fri, 11 Jan 2019 01:29:55 -0500 +Subject: [PATCH] procps-ng: add -M and -N options for top + +Signed-off-by: xuchunmei +Signed-off-by: zhoujie +--- + top/top.c | 15 ++++++++++++++- + top/top_nls.c | 2 ++ + 2 files changed, 16 insertions(+), 1 deletion(-) + +diff --git a/top/top.c b/top/top.c +index 04cf084..fbf0236 100644 +--- a/top/top.c ++++ b/top/top.c +@@ -4076,7 +4076,7 @@ default_or_error: + * overridden -- we'll force some on and negate others in our + * best effort to honor the loser's (oops, user's) wishes... */ + static void parse_args (int argc, char **argv) { +- static const char sopts[] = "bcd:E:e:Hhin:Oo:p:SsU:u:Vw::1"; ++ static const char sopts[] = "bcd:E:e:Hhin:Oo:p:SsU:u:Vw::1MN:"; + static const struct option lopts[] = { + { "batch-mode", no_argument, NULL, 'b' }, + { "cmdline-toggle", no_argument, NULL, 'c' }, +@@ -4097,6 +4097,8 @@ static void parse_args (int argc, char **argv) { + { "version", no_argument, NULL, 'V' }, + { "width", optional_argument, NULL, 'w' }, + { "single-cpu-toggle", no_argument, NULL, '1' }, ++ { "sort-by-mem", no_argument, NULL, 'M' }, ++ { "display-task-num", required_argument, NULL, 'N' }, + { NULL, 0, NULL, 0 } + }; + float tmp_delay = FLT_MAX; +@@ -4219,6 +4221,17 @@ static void parse_args (int argc, char **argv) { + error_exit(fmtmk(N_fmt(BAD_widtharg_fmt), cp)); + Width_mode = (int)tmp; + continue; ++ case 'M': ++ { ++ Curwin->rc.sortindx = EU_MEM; ++ break; ++ } ++ case 'N': ++ { ++ if (sscanf(cp, "%d", &Curwin->rc.maxtasks) != 1 || Curwin->rc.maxtasks < 0) ++ error_exit(fmtmk("bad iterations arg '%s'", cp)); ++ continue; ++ } + default: + // we'll rely on getopt for any error message ... + bye_bye(NULL); +diff --git a/top/top_nls.c b/top/top_nls.c +index 92f12ba..2e9c7fd 100644 +--- a/top/top_nls.c ++++ b/top/top_nls.c +@@ -409,6 +409,8 @@ static void build_norm_nlstab (void) { + " -u, --filter-only-euser =USER show only processes owned by USER\n" + " -w, --width [=COLUMNS] change print width [,use COLUMNS]\n" + " -1, --single-cpu-toggle reverse last remembered '1' state\n" ++ " -M, --sort-by-mem show tasks by memory usage\n" ++ " -N, --show-task-num show the specified number of tasks\n" + "\n" + " -h, --help display this help text, then exit\n" + " -V, --version output version information & exit\n" +-- +2.33.0 + diff --git a/0001-top-fix-two-potential-alternate-display-mode-abends.patch b/0001-top-fix-two-potential-alternate-display-mode-abends.patch deleted file mode 100644 index 1606408dbed57f3e4020397bc38d577f29c24f31..0000000000000000000000000000000000000000 --- a/0001-top-fix-two-potential-alternate-display-mode-abends.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 84e85611c36d31a478e1b62e5668671d9389265d Mon Sep 17 00:00:00 2001 -From: Jim Warner -Date: Mon, 31 May 2021 00:00:00 -0500 -Subject: [PATCH] top: fix two potential 'alternate display mode' abends - -This commit will address potential abends upon leaving -the windows help or color mapping screens and invoking -alternate display mode ('A'). It only happens if that -current window was changed with multiple 'a'/'w' keys. - -So now, rather than leaving a trail of negative values -in the 'begtask' field, compliments of that win_select -function, we'll remove the mkVIZrow1 macro. Henceforth -it will be issued just once per user interaction. Thus -a promise of 'Curwin' only being impacted is restored. - -[ my thanks to Vladimir Chren for reporting this bug ] - -Reference(s): -https://gitlab.com/procps-ng/procps/-/issues/210 -https://gitlab.com/procps-ng/procps/-/merge_requests/135 - -Discovered by:Vladimir Chren -Signed-off-by: Jim Warner ---- - top/top.c | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -diff --git a/top/top.c b/top/top.c -index c1f30fb..dd6e3d5 100644 ---- a/top/top.c -+++ b/top/top.c -@@ -4475,7 +4475,6 @@ static WIN_t *win_select (int ch) { - break; - } - Curwin = w; -- mkVIZrow1(Curwin); - return Curwin; - } // end: win_select - -@@ -5148,6 +5147,7 @@ static void keys_global (int ch) { - case '?': - case 'h': - help_view(); -+ mkVIZrow1(Curwin); - break; - case 'B': - TOGw(w, View_NOBOLD); -@@ -5175,6 +5175,7 @@ static void keys_global (int ch) { - break; - case 'g': - win_select(0); -+ mkVIZrow1(Curwin); - break; - case 'H': - Thread_mode = !Thread_mode; -@@ -5254,6 +5255,7 @@ static void keys_global (int ch) { - break; - case 'Z': - wins_colors(); -+ mkVIZrow1(Curwin); - break; - case '0': - Rc.zero_suppress = !Rc.zero_suppress; -@@ -5573,7 +5575,10 @@ static void keys_window (int ch) { - break; - case 'a': - case 'w': -- if (ALTCHKw) win_select(ch); -+ if (ALTCHKw) { -+ win_select(ch); -+ mkVIZrow1(Curwin); -+ } - break; - case 'G': - if (ALTCHKw) { --- -1.8.3.1 - diff --git a/0002-top-In-the-bye_bye-function-replace-fputs-with-the-w.patch b/0002-top-In-the-bye_bye-function-replace-fputs-with-the-w.patch deleted file mode 100644 index 92e805901bec770a52d92b306883a347c17d7e03..0000000000000000000000000000000000000000 --- a/0002-top-In-the-bye_bye-function-replace-fputs-with-the-w.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 0bf15c004db6a3342703a3c420a5692e376c457d Mon Sep 17 00:00:00 2001 -From: Shaohua Zhan -Date: Thu, 3 Dec 2020 10:24:09 +0800 -Subject: [PATCH] top: In the bye_bye function, replace fputs with the write - interface. - -When top calls malloc, if a signal is received, it will -call sig_endpgm to process the signal. In the bye_bye function, if the --b option is enable, the Batch variable is set, the fputs function -will calls malloc at the same time. The malloc function is not reentrant, so -it will cause the program to crash. - -Signed-off-by: Shaohua Zhan ---- - top/top.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/top/top.c b/top/top.c -index 2ec6357..eb62001 100644 ---- a/top/top.c -+++ b/top/top.c -@@ -571,7 +571,9 @@ static void bye_bye (const char *str) { - fputs(str, stderr); - exit(EXIT_FAILURE); - } -- if (Batch) fputs("\n", stdout); -+ if (Batch) { -+ write(fileno(stdout), "\n", sizeof("\n")); -+ } - exit(EXIT_SUCCESS); - } // end: bye_bye - --- -1.8.3.1 - diff --git a/0004-top-exit-with-error-when-pid-overflow.patch b/0002-top-exit-with-error-when-pid-overflow.patch similarity index 41% rename from 0004-top-exit-with-error-when-pid-overflow.patch rename to 0002-top-exit-with-error-when-pid-overflow.patch index 12a0f7e30080b010d1fa579bbd2d37f6cedb2257..8df3d5b53505da109e2c6a262f7abd570a87bce9 100644 --- a/0004-top-exit-with-error-when-pid-overflow.patch +++ b/0002-top-exit-with-error-when-pid-overflow.patch @@ -9,19 +9,18 @@ Signed-off-by: xuchunmei 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/top/top.c b/top/top.c -index 9bfc7f0..d1dbf95 100644 +index fbf0236..4bcfff0 100644 --- a/top/top.c +++ b/top/top.c -@@ -4098,7 +4098,8 @@ static void parse_args (char **args) { - if (Monpidsidx >= MONPIDMAX) - error_exit(fmtmk(N_fmt(LIMIT_exceed_fmt), MONPIDMAX)); - if (1 != sscanf(cp, "%d", &pid) -- || strpbrk(cp, "+-.")) -+ || strpbrk(cp, "+-.") -+ || 0 > pid) - error_exit(fmtmk(N_fmt(BAD_mon_pids_fmt), cp)); - if (!pid) pid = getpid(); - for (i = 0; i < Monpidsidx; i++) --- -1.8.3.1 - +@@ -4189,7 +4189,8 @@ static void parse_args (int argc, char **argv) { + if (Monpidsidx >= MONPIDMAX) + error_exit(fmtmk(N_fmt(LIMIT_exceed_fmt), MONPIDMAX)); + if (1 != sscanf(cp, "%d", &pid) +- || strpbrk(cp, "+-.")) ++ || strpbrk(cp, "+-.") ++ || 0 > pid) + error_exit(fmtmk(N_fmt(BAD_mon_pids_fmt), cp)); + if (!pid) pid = getpid(); + for (i = 0; i < Monpidsidx; i++) +-- +2.33.0 \ No newline at end of file diff --git a/0003-add-options-M-and-N-for-top.patch b/0003-add-options-M-and-N-for-top.patch deleted file mode 100644 index efe2ff0886c499aef0737ce7534e1d022a5e6204..0000000000000000000000000000000000000000 --- a/0003-add-options-M-and-N-for-top.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 6e59f5e746c15df4d4b53f2df85b64aa1f10d0c3 Mon Sep 17 00:00:00 2001 -From: xuchunmei -Date: Fri, 11 Jan 2019 01:29:55 -0500 -Subject: [PATCH] procps-ng: add -M and -N options for top - -Signed-off-by: xuchunmei ---- - top/top.c | 17 +++++++++++++++++ - top/top_nls.c | 2 +- - 2 files changed, 18 insertions(+), 1 deletion(-) - -diff --git a/top/top.c b/top/top.c -index b53e532..20cf7a1 100644 ---- a/top/top.c -+++ b/top/top.c -@@ -4337,6 +4337,23 @@ static void parse_args (char **args) { - args += ai; - if (pn) cp = pn + ci; - } continue; -+ case 'M': -+ { -+ Curwin->rc.sortindx = EU_MEM; -+ break; -+ } -+ case 'N': -+ { -+ if (cp[1]) -+ cp++; -+ else if (*args) -+ cp = *args++; -+ else -+ error_exit("-N requires argument"); -+ if (sscanf(cp, "%d", &Curwin->rc.maxtasks) != 1 || Curwin->rc.maxtasks < 0) -+ error_exit(fmtmk("bad iterations arg '%s'", cp)); -+ break; -+ } - default : - error_exit(fmtmk(N_fmt(UNKNOWN_opts_fmt) - , *cp, Myname, N_txt(USAGE_abbrev_txt))); -diff --git a/top/top_nls.c b/top/top_nls.c -index ab3029e..97c3468 100644 ---- a/top/top_nls.c -+++ b/top/top_nls.c -@@ -350,7 +350,7 @@ static void build_norm_nlstab (void) { - Norm_nlstab[OFF_one_word_txt] = _("Off"); - /* Translation Hint: Only the following words should be translated - . secs (seconds), max (maximum), user, field, cols (columns)*/ -- Norm_nlstab[USAGE_abbrev_txt] = _(" -hv | -bcEeHiOSs1 -d secs -n max -u|U user -p pid(s) -o field -w [cols]"); -+ Norm_nlstab[USAGE_abbrev_txt] = _(" -hv | -bcEeHiOSs1 -d secs -n max -u|U user -p pid(s) -o field -w [cols] -M -N num"); - Norm_nlstab[FAIL_statget_txt] = _("failed /proc/stat read"); - Norm_nlstab[FOREST_modes_fmt] = _("Forest mode %s"); - Norm_nlstab[FAIL_tty_get_txt] = _("failed tty get"); --- -2.27.0 - diff --git a/0005-fix-a-fix-for-the-bye_bye-function.patch b/0005-fix-a-fix-for-the-bye_bye-function.patch deleted file mode 100644 index d427a251ea03b373aa4fab3e243db3430041d53f..0000000000000000000000000000000000000000 --- a/0005-fix-a-fix-for-the-bye_bye-function.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 27e60e86e9f5b85520da001422176700fc9d824a Mon Sep 17 00:00:00 2001 -From: Jim Warner -Date: Mon, 21 Jun 2021 00:00:00 -0500 -Subject: [PATCH] top: fix a fix for the 'bye_bye' function (merge #127) - -In the merge request shown below, 1 too many bytes are -written to stdout thus including the terminating null. -As the cure, this commit just reduces the length by 1. - -[ along the way, we will remove some unneeded braces ] -[ plus add some additional comments with attribution ] - -Reference(s): -https://gitlab.com/procps-ng/procps/-/merge_requests/127 -. original ported cchange -commit 6b8980a3b6279058d727377e914cfb6439d6f178 - -Signed-off-by: Jim Warner - ---- - top/top.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/top/top.c b/top/top.c -index b3e1bcf..9248c7a 100644 ---- a/top/top.c -+++ b/top/top.c -@@ -572,7 +572,7 @@ static void bye_bye (const char *str) { - exit(EXIT_FAILURE); - } - if (Batch) { -- write(fileno(stdout), "\n", sizeof("\n")); -+ write(fileno(stdout), "\n", sizeof("\n") - 1); - } - exit(EXIT_SUCCESS); - } // end: bye_bye --- -1.8.3.1 - diff --git a/procps-ng-3.3.17.tar.xz b/procps-ng-3.3.17.tar.xz deleted file mode 100644 index 01e71c11f09ed08838782d3bdb54d6f3f4dd760c..0000000000000000000000000000000000000000 Binary files a/procps-ng-3.3.17.tar.xz and /dev/null differ diff --git a/procps-ng-4.0.0.tar.xz b/procps-ng-4.0.0.tar.xz new file mode 100644 index 0000000000000000000000000000000000000000..f271d29bdcd540826607b54c86f3eae79653a31b Binary files /dev/null and b/procps-ng-4.0.0.tar.xz differ diff --git a/procps-ng.spec b/procps-ng.spec index 84e0c8221b449a4d0a927fdbf23c6e1999f75b5d..aa38628d597dd2d7cec6649ac564f5499113e90f 100644 --- a/procps-ng.spec +++ b/procps-ng.spec @@ -1,6 +1,6 @@ Name: procps-ng -Version: 3.3.17 -Release: 3 +Version: 4.0.0 +Release: 1 Summary: Utilities that provide system information. License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+ URL: https://sourceforge.net/projects/procps-ng/ @@ -9,11 +9,8 @@ Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz Source1: README.md Source2: README.top -Patch1: 0001-top-fix-two-potential-alternate-display-mode-abends.patch -Patch2: 0002-top-In-the-bye_bye-function-replace-fputs-with-the-w.patch -Patch3: 0003-add-options-M-and-N-for-top.patch -Patch4: 0004-top-exit-with-error-when-pid-overflow.patch -Patch5: 0005-fix-a-fix-for-the-bye_bye-function.patch +Patch1: 0001-add-M-and-N-options-for-top.patch +Patch2: 0002-top-exit-with-error-when-pid-overflow.patch BuildRequires: ncurses-devel libtool autoconf automake gcc gettext-devel systemd-devel systemd-pam @@ -45,7 +42,7 @@ The package is used for the Internationalization of %{name} %package_help %prep -%autosetup -n procps-%{version} -p1 +%autosetup -n procps-ng-%{version} -p1 cp -p %{SOURCE1} . cp -p %{SOURCE2} top/ @@ -71,10 +68,10 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof %doc COPYING COPYING.LIB %{!?_licensedir:%global license %%doc} %license COPYING COPYING.LIB -%{_libdir}/libprocps.so.* +%{_libdir}/libproc-2.so.* %{_bindir}/* %{_sbindir}/* -%exclude %{_libdir}/libprocps.la +%exclude %{_libdir}/libproc-2.la %exclude /unwanted/* %exclude %{_libdir}/*.a @@ -82,9 +79,9 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof %doc COPYING COPYING.LIB %{!?_licensedir:%global license %%doc} %license COPYING COPYING.LIB -%{_libdir}/libprocps.so -%{_libdir}/pkgconfig/libprocps.pc -%{_includedir}/proc +%{_libdir}/libproc-2.so +%{_libdir}/pkgconfig/libproc-2.pc +%{_includedir}/procps %files i18n -f %{name}.lang @@ -93,6 +90,9 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof %{_mandir}/man* %changelog +* Thu Nov 3 2022 zhoujie - 4.0.0-1 +- update the release to 4.0.0-1 + * Tue Oct 25 2022 zhoujie - 3.3.17-3 - update the release to 3